compiler

regular expression for bit strings with even number of 1s

Let L= { w in (0+1)* | w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L? A) (0*10*1)* B) 0*(10*10*)* C) 0*(10*1)* 0* D) 0*1(10*1)* 10* According to me option D is never correct because it does not represent the bit string with zero 1s. But ...

What code have you written with #pragma you found useful?

I've never understood the need of #pragma once when #ifndef #define #endif always works. I've seen the usage of #pragma comment to link with other files, but setting up the compiler settings was easier with an IDE. What are some other usages of #pragma that is useful, but not widely known? Edit: I'm not just after a list of #pragma d...

Is there a tool for generating a DSL parser that does not require a runtime for the resultant parser?

I'm doing a lot of work with a DSLs at the moment and was wondering if anyone knew of a tool that could generate a parser for my bnf specification that does not require a run-time library (pure java source parser)? I'm committed to using XTEXT for a future Eclipse plug-in but I need a nice small version for my library itself and don't w...

Pragmas swp,ivdep,prefetch support in various compilers

Hello In good Altix manual (altix_single_cpu_optimization) I've found this list of pragmas-hints for optimizing compilers #pragma ivdep // no aliasing #pragma swp // try to software-pipeline #pragma noswp // disable software-pipelining #pragma loop count (NN) // hint for SWP #pragma distr...

nested function call faster or not ?

I have this silly argument with a friend and need an authoritative word on it. I have these two snippet and want to know which one is faster ? [A or B] (assuming that compiler does not optimize anything) [A] if ( foo () ); [B] int t = foo (); if ( t ) EDIT : Guys, this might look a silly question to you but I have a hardware ...

strange Xcode error Could not compile reconstructed dtrace script:

Hello all , i am getting this error when i try to compile an iPhone app. error: Could not compile reconstructed dtrace script: provider CorePlot { probe layer_position_change(char *,int,int,int,int); }; #pragma D attributes PRIVATE/PRIVATE/UNKNOWN provider CorePlot provider #pragma D attributes PRIVATE/PRIVATE/UNKNOWN provi...

What Should be the Structure of a C++ Project?

I have recently started learning C++ and coming from a Ruby environment I have found it very hard to structure a project in a way that it still compiles correctly, I have been using Code::Blocks which is brilliant but a downside is that when I add a new header file or c++ source file, it will generate some code and even though it is only...

Solutions for redundant server and client code?

In our system, the code which exists on the client side (in Flash and Javascript) mirrors the code that exists on the server side (e.g. in Python or PHP), normally with respect to the models, the methods available for those models, and the unit tests written for them. This becomes a problem in systems where you want to minimize data tran...

Easy way to convert c code to assembly?

Is there an easy way (like a free program) that can covert c/c++ code to x86 assembly? I know that any c compiler does something very similar and that I can just compile the c code and then disassemble the complied executable, but that's kind of an overkill, all I want is to convert a few lines of code. Does anyone know of some program...

armv6 / armv7 errors when compiling for iPhone

I am having problems trying to compile my App to my iPhone. I upgraded to the new SDK and have 4.0 on my phone... which I did not do that. I am compiling for 3.1.2 - It works fine in the simulator but when I "build" for the Device, it gives me this line of errors: Link /Users/me/Apps/myapp/build/app.build/Debug-iphoneos/app.build/object...

Compiler construction and DirectX

Hi! I am a beginner in the process of designing and coding a project, I already have all the ideas on my head, but I have a problem impeding me of continuing this project. I feel the code is ugly and unreadable and I cannot continue it this way. The project is a programming language I have on my mind, and it has small graphics capabilit...

Trying to compile MobileSubstrate addon - Undefined symbol

Hi! I went through this tutorial to create a MobileSubstrate addon. I could compile the example hook without errors. But as soon as I add #import <SpringBoard/SBAwayController.h> in ExampleHookProtocol.h and SBAwayController *awayController = [SBAwayController sharedAwayController]; in ExampleHookLibrary.mm (as the first line of...

Trying to 'Make' CUDA SDK, ld cannot find library, ldconfig says it can.

I know there are many other questions similar to this one, but none of the solutions posited there are working for me Basically, making the SDK sample files, i get /usr/bin/ld: cannot find -lcuda which would be an easy enough 'find the library and throw it to ldconfig', except ldconfig already says it has it... $ sudo ldconfig -v | gr...

static arrays defined with unspecified size, empty brackets?

For the C++ code fragment below: class Foo { int a[]; // no error }; int a[]; // error: storage size of 'a' isn't known void bar() { int a[]; // error: storage size of 'a' isn't known } why isn't the member variable causing an error too? and what is the meaning of this member variable? I'm using gcc version 3.4.5 (mingw...

Visual Studio 2010: COBOL in VS 2010, missing?

Is it true that Visual Studio 2010 has now COBOL compiler inside? I saw this in one article. I also saw a video of it. The question is, where can I find it? I've been searching VS2010 and still, no clues. Thanks for answering. ...

Can compiler optimization introduce bugs ?

Hi, Today I had a discussion with a friend of mine and we debated for a couple of hours about "compiler optimization". I defended the point that sometimes, a compiler optimization might introduce bugs or at least, undesired behavior. My friend totally disagreed, saying that "compilers are built by smart people and do smart things" and...

How can I compile Open CL on Mac OS X 10.6.3?

I was able to follow instructions and compiled CUDA 3.0 but cannot compile OpenCL that goes with it on Mac OS X 10.6.3? ...

Stack / base pointers in assembly

I know this topic has been covered ad nauseam here, and other places on the internet - but hopefully the question is a simple one as I try to get my head around assembly... So if i understand correctly the ebp (base pointer) will point to the top of the stack, and the esp (stack pointer) will point to the bottom -- since the stack grow...

Can the Perl compiler tell me if I have an unchecked exception in my code?

Is there a way in Perl to declare that a method can throw an error (or die)? EDIT: What interests me the most is a way to get the compiler or IDE to tell me I have an unchecked exception somewhere in my code. I always loved how in Java, a method could handle an Exception and/or throw it. The method signature allows to put "throws MyExc...

Exception: "Invalid action number found in internal parse table." Polyglot Exception

I am using an Compiler called Polyglot which is a highly extendable compiler for Java. I seem to have run into this Exception while trying to compile some test code: "Invalid action number found in internal parse table." How can I make a valid action number for the parse table? EDIT: I solved the problem by just fixing my gram...