compiler

How to compare compilers

What pointers do you use to compare between compilers? I'm told gcc is the best C compiler, is this true? If so, why? I mean this generally, so you can state which compiler is more appropriate for which architecture. (I hear igc would be more appropriate for Intel for instance, but I don't know why) Personally I intend to use AMD 64 ...

SCCS "what" strings not optimised away by the compiler

We try and embed a what string within binary objects so that we can see the version number for an executable or shared library that has been deployed. Typically we embed standard CVS Id information in this what string. For example, we might embed: const char cvsid[] = "@(#)OUR_TEAM_staging_remap_$Revision: 1.30 $ $Name: $"; within th...

define a preprocessor value from command line using MSBuild

I need to create a demo version of an existing large application consisting of multiple projects. I'd like to use the existing projects, and just neuter the functionality via preprocessor directives #if DEMO mycode.NeuterNow(); #endif We are building our app using MSBuild, and I'd ideally use something along the lines of: MSBui...

Recursive Descent vs. Generated Parsers - Efficiency

How do hand-written recursive descent parsers (which are inevitably LL(k)) compare to generated LALR parsers in terms of performance? I know that LALR parsers are able to handle far more grammars than LL(k); however it's my intention to write my parser by hand, and recursive descent seems the most appropriate choice. Is it possible to w...

Is Scalas/Haskells parser combinators sufficient?

I'm wondering if Scalas/Haskells parser combinators are sufficient for parsing a programming language. More specifically the language MiniJava. I'm currently reading compiller construction and jflex and java cup is quite painful to work with so I'm wondering if I could/should use parser combinators instead. The MiniJava syntax is very sm...

How can the Linux kernel compile itself?

I don't quite understand the compiling process of the Linux kernel when I install a Linux system on my machine. Here are some things that confused me: The kernel is written in C, however how did the kernel get compiled without a compiler installed? If the C compiler is installed on my machine before the kernel is compiled, how can th...

Why doesn't Sun do a C# to Java byte code compiler?

We Want to Run Our C# Code on the JVM My company has a large C# code base. Well over half of this code is our core engine for creating, reading, modifying, calculating and writing Excel workbooks. We frequently get questions from customers and potential customers asking whether we are going to build a Java version of our engine - many o...

Why are Virtual Machines necessary?

I was reading this question to find out the differences between the Java Virtual Machine and the .NET CLR and Benji's answer got me wondering why Virtual Machines are necessary in the first place. From my understanding of Benji's explanation, the JIT compiler of a Virtual Machine interprets the intermediate code into the actual assembly...

Why does autoboxing make some calls ambiguous in Java?

I noticed today that auto-boxing can sometimes cause ambiguity in method overload resolution. The simplest example appears to be this: public class Test { static void f(Object a, boolean b) {} static void f(Object a, Object b) {} static void m(int a, boolean b) { f(a,b); } } When compiled, it causes the following error: ...

Would you recommend ASN.1 to C# compiler?

Have you done any work with ASN.1 to C# compiler? Can you recommend it? I have used Objective Systems ASN1C which I would recommend. I have also played a little with BinaryNotes. ...

How would you re-use C opcode implementations when writing a JIT with LLVM ?

In the llvm tutorials and examples, the compiler outputs LLVM IR by making calls like this return Builder.CreateAdd(L, R, "addtmp"); but many interpreters are written like this: switch (opcode) { case ADD: result = L + R; break; ... How would you extract each of these code snippets to make a JIT ...

VS2005 C++ compiler problem including <comdef.h> in MFC application

I am having some trouble converting an old project from VS6 to VS2005. At one place in the code it uses the type variant_t so it includes comdef.h for this purpose. comdef.h then includes comutil.h which generates these errors for me: c:\program files\microsoft visual studio 8\vc\include\comutil.h(978) : error C2535: '_variant_t::_varia...

Checking string format at compile time in C#

In my code there are several strings which are used as keys to access resources. These keys have a specific format, e.g. string key = "ABC123"; Currently, all these keys are stored as strings, but I'd like to make things more robust and type-safe. Ideally, I'd like to check the strings are in the correct format at compile time. The n...

Will #if RELEASE work like #if DEBUG does in C#?

In all the examples I've seen of the #if compiler directive, they use "DEBUG". Can I use "RELEASE" in the same way to exclude code that I don't want to run when compiled in debug mode? The code I want to surround with this block sends out a bunch of emails, and I don't want to accidentally send those out when testing. ...

C# feature request: implement interfaces on anonymous types

I am wondering what it would take to make something like this work: using System; class Program { static void Main() { var f = new IFoo { Foo = "foo", Print = () => Console.WriteLine(Foo) }; } } interface IFoo { String Foo { get; set; } void Print(); } The...

Why do arrays start from zero?

Duplicate of: Defend zero-based arrays Why did the computer programming inventors have the brilliant idea of making arrays start with index zero and leave us all doing myArray.length()-1 when they knew that the logical thing would be to have the index start from 1? Is it some sort of backwards compatibility due to which all (even...

The compilation process

Can anyone explain how compilation works? I can't seem to figure out how compilation works.. To be more specific, here's an example.. I'm trying to write some code in MSVC++ 6 to load a Lua state.. I've already: set the additional directories for the library and include files to the right directories used extern "C" (because Lua i...

How to compile the generated AS

Hi guys, hope you can help me with this question. So, I've been working for a while with Flex, and had the crazy idea to create pure AS project. If I compile a Flex app with the -keep flag, the generated actionscript gets generated. Do you guys know of a way to make it compile, without going trough the code and gluing it all together?...

Compilers and beyond

I want to go backwards and learn more about how compilers, processors and memory operate on my programs. I am also interested in the physics on which all of this depends. Any good references or books would be appreciated... ...

Should I disable the C compiler signed/unsigned mismatch warning?

The Microsoft C compiler warns when you try to compare two variables, and one is signed, and the other is unsigned. For example: int a; unsigned b; if ( a < b ) { // warning C4018: '&lt;' : signed/unsigned mismatch } Has this warning, in the history of the world, ever caught a real bug? Why's it there, anyway? ...