compiler

Starting off a simple (the simplest perhaps) C compiler?

I came across this: Writing a compiler using Turbo Pascal I am curious if there are any tutorials or references explaining how to go about creating a simple C compiler. I mean, it is enough if it gets me to the level of making it understand arithmetic operations. I became really curious after reading this article by Ken Thompson. The id...

Calling a method with this pointer from an inherited class becomes const.

class A { } class B : public A { doSomething { C * c = new C(this); } } class C { C(A* copy); } In the following example I get the following error: error: no matching function for call to `C::C(B* const)' I wan't to get the A pointer in the this call but for some reason I can't get this through. Probably so...

conditional compilation statement in limits.h

I am not able to understand the following statement from the file limits.h. What is the use of this statement and what does it accomplishes? /* If we are not using GNU CC we have to define all the symbols ourself. Otherwise use gcc's definitions (see below). */ #if !defined __GNUC__ || __GNUC__ < 2 ...

Generating Assembly For an x86 Processor

I'm currently working my way through Andrew Appel's Modern Compiler Implementation in Java, and I'm right around the point where I build the low-level intermediate representation. Initially, I had decided to target the JVM and ignore all of the low-level machine stuff, but in the interest of learning things that I don't know much about ...

Does anyone know what the "-FC" option does in gcc g++?

Does anyone know what the "-FC" option does in g++? I have it in my SConstruct script that builds the command line g++ command, I have searched google ...

Using Mono Compiler/Creating a new one while still outputting a Windows EXE?

This is just a thought for now, but I wonder how hard it would be to either use the Mono Compiler or write a new one while still outputting a Windows EXE? The reason for this thought is that I see people "abusing" the C# language creatively to get some stuff like code contracts or aspect oriented programming up and running, and sometime...

How to set warning level in CMake?

How to set the warning level for a project (not the whole solution) using CMake? Should work on Visual Studio and GCC. I found various options but most seem either not to work or are not consistent with the documentation. ...

iphone compiler inherited templated base classes with passed through type not being expanded in time (just look)

Try this out: template <typename T> class Base { public: int someBaseMember; }; template <typename T> class Test: public Base<T> { public: void testFunc() { someBaseMember = 0; } }; In vc++ and the psp compiler (and any other compiler ...

[C++/C] C++ program gets undefined reference to a dynamic C library during linking

I've created a dynamic networking library in C. When I try to link it in my C++ program I get an undefined reference the first time I call one of my functions in the library. What I can't understand is that I created a little test program in C that uses the library and it links just fine. Could someone help with my problem? Here are the...

Howto get the java compiler to insert a variable name into a string

I often find myself writing code like this: throwExceptionWhenEmpty(fileType, "fileType"); throwExceptionWhenEmpty(channel, "channel"); throwExceptionWhenEmpty(url, "url"); The throwExceptionWhenEmpty method does something like this: private void throwExceptionWhenEmpty(final String var, final String varName) { if (var == null ||...

Where can I find CSharpEvaluator?

What Anders presents at minute 60 of this video seems pretty cool http://channel9.msdn.com/pdc2008/TL16/ However, I can't find it. Is it released? Is there an alternative? ...

C# Empty Statement

The C# language specification defines the empty-statement grammar production, which allows me to do something like this: static void Main(string[] args) { ; ; ; } Why would Microsoft include this grammar production in the C# language? Does it have a useful purpose? ...

g++ produce executable for windows

I am using gcc/g++ to compile c/c++ applications - living on OpenSuSe btw. Is there any way (some option i guess) so that g++ will produce an executable suitable for windows ? ...

IPhone compilation of ported code problems: sub class of template parameter base class inaccessible

check this out: template <class T> class Test: public T { public: void TestFunc() { T::SubClass bob; } }; this fails when compiling for iPhone (expected ';' before 'bob'). works on other platforms this is a simplified example of what we are actually trying to do, which is inherit from an std::map<> and inside tha...

IPhone compilation of ported code problems: variable given same name as typedef'd type failing

check this out: this compiles fine on iPhone: typedef int ATYPE; void AFunc() { ATYPE ATYPE; ATYPE = 1337; } this compiles fine on iPhone: typedef int ATYPE; typedef ATYPE _ATYPE; struct AStruct { _ATYPE ATYPE; }; void AFunc() { AStruct bob; bob.ATYPE = 1337; } but this does NOT: typedef int ATYPE; struct ...

VS 2008 C++ build output?

Why when I watch the build output from a VC++ project in VS do I see: 1>Compiling... 1>a.cpp 1>b.cpp 1>c.cpp 1>d.cpp 1>e.cpp [etc...] 1>Generating code... 1>x.cpp 1>y.cpp [etc...] The output looks as though several compilation units are being handled before any code is generated. Is this really going on? I'm t...

How does an interpreter/compiler work

How does an interpreter/compiler work? What is the difference between interpreter and compiler. ...

How to recompile Java Runtime Environment (JRE)?

I thought this would be very easy. I downloaded the JDK, extracted src.zip, modified the JDK to fit my needs and saved the file. Now, the only thing I need to do is recompile the extracted and update src folder to a "JRE". I tried using javac, but didn't get anywhere. For example, I got the error that no source files were given. I am ob...

Which assembler to target?

I'm building a toy compiler as a learning project, and I'm hovering around the code generation phase right now. I found this page describing a host of different assemblers that I could target, and I'd like some recommendations on which to choose. My goal is to optimize my learning experience - to that end, I've tried to make decisions ...

Java for loop performance question

Hi, considering this example: public static void main(final String[] args) { final List<String> myList = Arrays.asList("A", "B", "C", "D"); final long start = System.currentTimeMillis(); for (int i = 1000000; i > myList.size(); i--) { System.out.println("Hello"); } final long stop = System.currentTimeMillis(...