I've been getting into compiler creation. I've found some terrific beginner stuff and advanced stuff but nothing in the middle. I've created 3 different simple proof-of-concept compilers for toy languages but I want to expose myself to something real.
The most straight forward real language in terms of syntax seems to be C. Since the la...
I maintain several modest-sized C programs, and I frequently have a use for fully accurate cross-reference information. Unlike "tags" or other approximations, such information is typically generated by a compiler that knows the full scoping rules of the C language and can provide accurate information accordingly. For example, here is a...
I have the following code snippet:
enum { one } x;
enum { two } y;
x = y;
That will compile in C, but in C++, I get the following error:
test.c:6: error: cannot convert ‘main()::<anonymous enum>’ to ‘main()::<anonymous enum>’ in assignment
Can someone explain to me why this is happening? I would prefer an answer with some specifics...
say I have:
class Test
{
public static int Hello = 5;
}
This obviously works:
int j = Test.Hello;
But why should this not work?
Test test = new Test();
int j = test.Hello;
The instance could not have a member equally named, so I don't see how this could be ambiguous or unresolvable for a compiler.
Anyone any idea wh...
Why does the following give no compilation error?:
// T.h
template<class T> class X
{
public:
void foo(int a = 42);
};
// Main.cpp
#include "T.h"
#include <iostream>
template<class T> void X<T>::foo(int a = 13)
{
std::cout << a << std::endl;
}
int main()
{
X<int> x;
x.foo(); // prints 42
}
It seems as thoug...
Are there any auto compiling scripts like the ones used at ideone.com and codepad.org available?
(preferably open source, and which execute the code in a safe environment.)
...
Okay I'm looking for some input, I'm pretty sure this is not currently supported in .NET 3.5 but here goes.
I want to require a generic type passed into my class to have a constructor like this:
new(IDictionary<string,object>)
so the class would look like this
public MyClass<T> where T : new(IDictionary<string,object>)
{
T Creat...
Hello,
What is the fastest C++ compiler possible. I want to compile C++ version of LZMA. I did compile it using Visual Studio .NET, but it is not fast enough for my job. In addition, I need to change the Compiler settings in order to make it as fast as possible. I would appreciate if you introduce me a fast compiler and/or some informat...
I have the following code:
#include <boost/shared_ptr.hpp>
struct Foo { int a; };
static int A;
void
func_shared(const boost::shared_ptr<Foo> &foo) {
A = foo->a;
}
void
func_raw(Foo * const foo) {
A = foo->a;
}
I thought the compiler would create identical code, but for shared_ptr version an extra seemingly redundant instru...
i am developing parser using bison...in my grammar i am getting this error
Here is a code
extern NodePtr CreateNode(NodeType, ...);
extern NodePtr ReplaceNode(NodeType, NodePtr);
extern NodePtr MergeSubTrees(NodeType, ...);
...................
NodePtr rootNodePtr = NULL; /* pointer to the root of the parse tree...
I've found recently that for some types of financial calculations that the following pattern is much easier to follow and test especially in situations where we may need to get numbers from various stages of the computation.
public class nonsensical_calculator
{
...
double _rate;
int _term;
int _days;
double mont...
Hi all,
I'm interested in knowing how GCC differs from Intel's ICC in terms of the optimization levels and catering to specific processor architecture. I'm using GCC 4.1.2 20070626 and ICC v11.1 for Linux.
How does ICC's optimization levels (O1 to O3) differ from GCC, if they differ at all?
The ICC is able to cater specifically to dif...
I'm trying do build and debug a small project for BlackBerry.
During the build I'm getting this error Error preverifying class java ...
I read on the net this error could be caused by referencing multiple projects but I tried to move every package in a single project but the error is still there.
I tried with multiple JDE version (cur...
Hi All,
I am porting a very large code base and I am having more difficulty with old code.
For example, this causes a compiler error:
inline CP_M_ReferenceCounted *
FrAssignRef(CP_M_ReferenceCounted * & to, CP_M_ReferenceCounted * from)
{
if (from) from->AddReference();
if (to) to->RemoveReference();
to = from;
return ...
I know why the following code doesn't compile:
public class Main {
public static void main(String args[]) {
main((null)); // this is fine!
(main(null)); // this is NOT!
}
}
What I'm wondering is why my compiler (javac 1.6.0_17, Windows version) is complaining "The left hand side of an assignment must be a variable".
...
Recently I tried compiling program something like this with GCC:
int f(int i){
if(i<0){ return 0;}
return f(i-1);
f(100000);
and it ran just fine. When I inspected the stack frames the compiler optimized the program to use only one frame, by just jumping back to the beginning of the function and only replacing the arguments to...
If you've ever used Reflector, you probably noticed that the C# compiler generates types, methods, fields, and local variables, that deserve 'special' display by the debugger. For instance, local variables beginning with 'CS$' are not displayed to the user. There are other special naming conventions for closure types of anonymous methods...
I don't think this is currently possible or if it's even a good idea, but it's something I was thinking about just now. I use MSTest for unit testing my C# project. In one of my tests, I do the following:
MyClass instance;
try
{
instance = getValue();
}
catch (MyException ex)
{
Assert.Fail("Caught MyException");
}
instance.d...
Hi all,
I have a quite general question regarding false dependencies. As the name implies, these
are not real dependencies and can be eliminated. I am aware of the technique called register renaming that eliminates such dependencies at a hardware level. Of course I could eliminate these beforehand at a "higher" level when writing assemb...
I need to work on C++ project on my windows machine. My project will consist of various classes(.h and .cpp) as well as the startup file to start the application. The preliminary design is simple but the application has the potential to gain complexity as time goes by. What I need here is ideas to set up the C++ project compiler/IDE/Make...