compiler

GCC compiler error: "redefinition...previously defined"

I'm getting a lot of " redefinition of x....x previously defined here". Please what does this error means? ...

c++ compiling error related to constructor/destructor definition.

Hello, I'm trying to define the constructor and destructor of my class but I keep getting the error: definition of implicitly-declared 'x::x()'. What does it mean? BestWishes! Part of the code: ///Constructor StackInt::StackInt(){ t = (-1); stackArray = new int[20]; }; ///Destructor StackInt::~StackInt(){ delete[] stackArr...

Command Line Compiling a Win Forms C# Application

I'm trying to create a script to compile an Windows Forms C# 2.0 project from the command line (I know, I know.. I'm reinventing the wheel.. again.. but if somebody knows the answer, I'd appreciate it). The project is a standard Windows Forms project that has some resources and references a couple external assemblies. Here is a list of...

Need Help Understanding Compilers/HLL->Assembly

I am an electronics student and I have programmed mostly in Assembly. Last night I saw an amazing article that discussed writing a compiler in Ruby. What the author had done was use GCC to peek how the C translates to Assembly. That resonated a lot for me. I could finally see how the C program translated to Assembly.My question/request t...

Is there a way to have the c# compiler display warnings when a switch statement do have unhandled cases ?

Consider the following code : private enum myEnum { A, B } private void myMethod(myEnum m) { switch (m) { case myEnum.A: //do stuff break; case myEnum.B: //do stuf...

How method hiding works in C#?

Why the following program prints B B (as it should) public class A { public void Print() { Console.WriteLine("A"); } } public class B : A { public new void Print() { Console.WriteLine("B"); } public void Print2() { Pr...

How method hiding works in C#? (Part Two)

The following program prints A:C(A,B) B:C(A,B) (as it should) public interface I { string A(); } public class C : I { public string A() { return "A"; } public string B() { return "B"; } } public class A { public virtual void Print(C c) { Console.WriteLine("A:C(" + c.A() +...

How does static field initialization work in C#?

Should static field initialization be completed before constructor is called? The following program provides output that seems incorrect to me. new A() _A == null static A() new A() _A == A The code: public class A { public static string _A = (new A()).I(); public A() { Console.WriteLine("new A()"); if (...

Why C# is always winning over VB.NET?

I wrote a program that allow two classes to "fight". For whatever reason C# always wins. What's wrong with VB.NET ? static void Main(string[] args) { Player a = new A(); Player b = new B(); if (a.Power > b.Power) Console.WriteLine("C# won"); else if (a.Power < b.Power) Cons...

Is keyword 'event' optional in C#?

What is the difference between eventOne (with keyword 'event') and eventTwo (w/o keyword)? class Program { public event EventHandler eventOne; public EventHandler eventTwo; public void RaiseOne() { if (eventOne != null) eventOne(this, EventArgs.Empty); } public void RaiseTwo() { ...

How exactly keyword 'params' work?

The following code sample prints: T T[] T[] While first two lines are as expected, why compiler selected param array for a regular array? public class A { public void Print<T>(T t) { Console.WriteLine("T"); } public void Print<T>(params T[] t) { Console.WriteLine("T[]"); } } class Program { ...

Whats the best way to learn about VM implementation besides actually hacking code?

I'd like to learn more about VM implementation and optimization. Right now I'm contributing (in a small way) with JRuby and am also playing/writing with my own lisp-like language implementation that runs in a VM. However I'd like to get more information on working with VM's and designing them. Is there a good resource for this type of i...

Does the evil cast get trumped by the evil compiler?

This is not academic code or a hypothetical quesiton. The original problem was converting code from HP11 to HP1123 Itanium. Basically it boils down to a compile error on HP1123 Itanium. It has me really scratching my head when reproducing it on Windows for study. I have stripped all but the most basic aspects... You may have to press...

Why this specific operation overflow (cf. CS0220) in C# ?

I try to construct a big Int64 with nibble information stored in bytes. The following lines of code work as expected: Console.WriteLine("{0:X12}", (Int64)(0x0d * 0x100000000)); Console.WriteLine("{0:X12}", (Int64)(0x0d * 0x1000000)); Console.WriteLine("{0:X12}", (Int64)(0x0d * 0x100000)); Why does the following line lead to a compile...

Open source Visual Studio project distribution nightmare...

Every time Microsoft releases a new version of visual studio, they always require me to convert my solution and project files to 'the latest version.' Even with something as simple as a "Hello World" solution, I need to go through their conversion wizard! And, to make things worse, the new visual studio solution files aren't compatible...

How virtual events work in C# ?

Below is the program I used for the test. It prints (as expected): Raise A Event from A Raise B Event from B Now, if we change first two lines of the Main to be: A a = new B(); B b = new B(); the Program will print: Raise A Raise B Event from B which is also expected, as overriding event hides the private backing...

Does VB.NET support virtual events?

In continuation of this question. Does VB.NET supports virtual events? ...

Purdue Compiler Construction Tool Set (PCCTS) : website, tutorial, book?

I am a college student and have been asked to familiarize myself with PCCTS, Purdu Compiler Construction Tool Set. I have been given a link to http://www.polhode.com/pccts.html I have to code some basic program in PCCTS and later on use the knowledge in compiler optimization. As such there are a few results available on google for th...

How to make a .Net or JVM language?

I am seeing all these new languages for .NET and JVM. How does one begin to make one? I can't find any good documentation on JVM or MSIL specifications. Edit I already know how to parse, I am more interested in how there are so many people making new languages that are based on those platforms. ...

Live Range vs Reaching Definitions

In compiler data flow analysis, what is the difference between a live range of a variable and it's reaching definition? Both seem to refer to the same thing... ...