Questions tagged [compilationunit]
27 questions
1
vote
1 answer
Should a python file always include a class?
I have been coding in python for a couple months now, and something has always been on my mind. I know you can have classes in your .py file, but you don't have to. My question is, is it good practice to always have your code in a class, or is it…

Linny
- 818
- 1
- 9
- 22
1
vote
0 answers
Unable to parse code snippet in roslyn
I'm trying to dynamically build a c# class from small pieces of code. We have a window where a user can enter c# code (valid or not), and we parse these strings into roslyn. I recently found an issue when i was using this :
public override…

stongef
- 41
- 6
1
vote
1 answer
How do I get an IResource from an IEditorActionDelegate
I wrote an IEditorActionDelegate to fire from a context menu on a CompilationUnitEditor. From there I want to create a marker at the start line of the selected text. I have an ITextSelection, and an IEditorPart object. How can I get an IResource…

Jaime Garcia
- 6,744
- 7
- 49
- 61
1
vote
0 answers
java.lang.OutOfMemoryError: Java heap space on org.eclipse.jdt.core.dom.CompilationUnit
When I process one java file or a few, I have not problems, but if the number of java it is around 90 i get "java.lang.OutOfMemoryError: Java heap space". I have as Default VM Arguments in eclipse:
java.lang.OutOfMemoryError: -Xms1024M…

Clonw
- 75
- 6
0
votes
0 answers
Variable in C defined with 'inline' keyword
A variable defined with inline keyword in C++ allows definition of the variable in multiple compilation units and lets linker to resolve these multiple definitions into a single one, as it is explained here:…

cerveka2
- 156
- 7
0
votes
1 answer
Why am I getting NullPointerException in the CompilationUnit instances returned from ASTParser.createASTs()
I am working on an Eclipse JDT plugin that requires parsing large numbers of source files,
so I am hoping to use the batch method ASTParser.createASTs(). The parsing executes without errors, but within the CompilationUnit instances it produces, many…

Byron Hawkins
- 2,536
- 2
- 24
- 34
0
votes
2 answers
Class definition in cpp but meet error: invalid use of incomplete type
I define the struct A in the a.cpp in the first.
// a.cpp
#include"a.h"
struct A {
A(int num):a(num){}
…

Yushin Liu
- 31
- 4
0
votes
2 answers
Using a global variable to initialize other global variable in different compilation units
I have a shared library which exports a function that returns a string from a global variable like so:
test.h:
const std::string &test_get_name();
test.cpp:
static std::string name = "Test";
const std::string &test_get_name() {return name;}
In my…

Silverlan
- 2,783
- 3
- 31
- 66
0
votes
2 answers
How does the compiler and linker handle classes and functions
Can someone please help me to understand, why I can have the same class in two different compilation units without getting linker errors but not the same function in different compilation units?
Many thanks in advance.

abraham_hilbert
- 2,221
- 1
- 13
- 30
0
votes
1 answer
How to get problems in CompilationUnit regarding imports
I want to detect an error regarding an import statement. But compilation unit seems to detect errors inside the class declaration itself.
My code on which I am experimenting is as follows :
import java.text.SimpleDateFormat;
import…

aravindkanna
- 663
- 1
- 7
- 25
0
votes
1 answer
JavaCompiler didn't catch error on redefinition of a Java class.
During my Java learning, I tried this piece of code which compiled & ran successfully. Can anybody please provide an explanation that why hasn't the compiler generated any error? I imported the complete package which includes java.util>Scanner as…

WhiteSword
- 101
- 9
0
votes
2 answers
Unresolved symbol error
I'm working through exercises from Programming Principles and Practice using Visual Studio 2012. When trying to compile the source code below I'm getting a linker error:
unresolved symbol int foo.
I don't understand why the symbol is unresolved.…

dcrearer
- 1,972
- 4
- 24
- 48