Click here to Skip to main content
15,885,201 members
Everything / Compiler

Compiler

compiler

Great Reads

by Chris Boss
More about BASIC and what can be accomplished with the language
by honey the codewitch
An LL(1) pull parser and generator that thinks it's an LL(k) parser - with a rich, simple and beautiful EBNF syntax
by Dennis C. Dietrich
Clarifying how the .NET GC identifies objects to collect once and for all... hopefully...
by honey the codewitch
If you use the CodeDOM, here's an indispensable package to make it awesome.

Latest Articles

by Alex Rakov, Alexandre Bencz
ELENA is a general-purpose, object-oriented, polymorphic language with late binding
by AmrDeveloper
Introduce GQL (A Git Query Language) to perform SQL like queries on .git files
by Coral Kashri
How compiler helps code run faster and generates warnings in single cross-compiler way
by DavesApps
A way to catch / prevent race conditions in multithreaded code

All Articles

Sort by Score

Compiler 

15 Nov 2022 by Chris Boss
More about BASIC and what can be accomplished with the language
14 May 2019 by honey the codewitch
An LL(1) pull parser and generator that thinks it's an LL(k) parser - with a rich, simple and beautiful EBNF syntax
9 Aug 2013 by Dennis C. Dietrich
Clarifying how the .NET GC identifies objects to collect once and for all... hopefully...
7 Feb 2013 by Sergey Alexandrovich Kryukov
We cannot discuss all C++ libraries, can only focus on UI development, which the the topic most difficult for cross-platform development. I also don't want to discuss anything commercial (like VCL), except Visual Studio which I guess you have.You already know about Qt. (I answered here: is...
7 Jan 2011 by Sandeep Mewara
How about this: Open Source Visual Basic.Net Compiler[^]For other/more: Google Search result[^]
7 Jan 2011 by Manfred Rudolf Bihy
Please take also this tool into consideration:ANTLR[^]There is a C# version available on the download site:ANTLR download[^] Caution commercial product: This one is pretty easy to handle even for beginners. My sister could do it and she isn't even a...
7 Jan 2011 by CPallini
If you want to learn how to build a simple compiler (without using tools) then "Let's build a compiler, by Jack Crenshaw"[^] may be a worthy reading. :)
11 Dec 2019 by honey the codewitch
If you use the CodeDOM, here's an indispensable package to make it awesome.
15 Apr 2023 by DavesApps
A way to catch / prevent race conditions in multithreaded code
7 Jan 2011 by Espen Harlinn
You can start by looking at http://www.antlr.org/[^]and http://boost-spirit.com/home/[^]Antlr is a parser generator, with lots of extra goodies. Generates code for java, c#, c, and other programming laguages.boost spirit allows you to define your parser directly in C++, using...
20 Jun 2010 by Richard MacCutchan
Louis Cooper wrote:IMPLIMENT_APP(MyApp)Should be IMPLEMENT_APP(MyApp)
25 Apr 2011 by OriginalGriff
Phew! You get my 5 for the most ambitious, sensible question I have yet seen! :laugh:That is a heck of a lot of work, and in a lot of disciplines. Some of those 5 areas are the subject of university courses all on their own...My suggestion is: start small.Look at getting a pre-built...
31 May 2012 by CPallini
There are several good books on writing compilers (see, for instance the classic 'teoric' Dragon Book[^] or 'more pragmatic' Fraser and Hanson's one[^]).It is worth noting that building a C++ compiler is a daunting task (C++ is a damned complex language).
16 Sep 2013 by OriginalGriff
This doesn't do C, or Python - it works with a simple demo language it calls Kaleidoscope - but it is a tutorial on writing a compiler from scratch: http://llvm.org/docs/tutorial/[^]Be aware - it's a lot of work, and there is no actual reason that you need to write a compiler in order to...
8 Jan 2017 by Miguel Diaz Kusztrich
Object creation driven by source code in any language you have designed
20 Aug 2019 by honey the codewitch
Using PCK to create grammars, parsers and tokenizers for C# and other .NET languages
28 Apr 2010 by CPallini
Josh Gray wrote:* Is there likely to be a tangible benefit to doing this or would a compiler (gcc in my case) make this optimisation?VC++ compiler takes care of such optimization (I see no div operation).I guess gcc do the same, you may verify it using the -S switch and looking at the...
27 May 2010 by Anu Koshy
May be you have included "CDragDrop.h" file before "stdafx.h", as follow:#include "CDragDrop.h"#include "stdafx.h"to fix the problem, write all the file inclusions after the #include "stdafx.h" statement.It should be like this:#include "stdafx.h"#include "CDragDrop.h"
3 Jun 2010 by r.ps
CPallini has given you the answer. But be aware of something called 'structure padding'. Look it up.
7 Dec 2010 by Alain Rist
Hi Rajesh,Use the Visual Studio Configuration Manager (in Build menu) to create different project configurations, see How to: Create and Edit Configurations[^].Use compile time definitions to adjust specific configuration features.cheers,AR
25 Apr 2011 by Sergey Alexandrovich Kryukov
I am not really sure you are serious. I even suspected this is a kind of trolling.But if you are serious…I really sympathize with you and respect your thirst for knowledge and understanding.First of all, you should understand you're going to live a very difficult like, and not...
5 May 2011 by Abhinav S
You might want to start from here.
26 Nov 2011 by Jammer
Hi All,I've been looking into AOP lately for a project and was wondering what the general consensus was in .NET land on this issue?There are a few different approaches to this one can take, seems that the "pure" idea of AOP is performing compiler weaving with tools such as PoitSharp. ...
17 Apr 2012 by Sergey Alexandrovich Kryukov
You are using pretty wise method of getting assembly location without messing with file systems. You should run this code under debugger and see what's wrong with "Samwin.UnitTest.dll" and compare with its real location, but I can suggest that the problem is simple: this assembly is not included...
13 Jul 2014 by Sergey Alexandrovich Kryukov
The two pieces of the code are fundamentally different. And this is quite clear.Your 3 variables statically occupy 3 slots in memory after the code is loaded. As to the struct, it occupies none, but instantiation of MyStruct does get memory (it's not the fact that exactly the same, as it...
12 Jun 2013 by parths
Try checking the assembly output for yourself. Going through the assembly generated by a compiler can be quite interesting.For example, in gcc you can use the -S command line optionWith Visual studio, go to project properties->Configuration Properties->C/C++->Output Files and set the...
22 Nov 2013 by Sergey Alexandrovich Kryukov
In addition to other answers: I would advice you to focus on code maintenance and readability and ignore the possibilities for such small "optimizations": most usually, they won't actually "optimize" anything. As to the readability differences between your two samples, there is no clear...
13 Apr 2014 by OriginalGriff
Creating your own compiler is not a trivial job: it's a lot of careful design and coding, if you want it to be any use in the real world.There are a lot of books on compiler design: Google[^] can help you get started.Some of the stuff there is "Free" - I don't know if that means "stolen" -...
22 Nov 2015 by OriginalGriff
Assembly language doesn't use a compiler - only high level languages need that. Assembly language is processed to machine code via an assembler, which is a different type of program altogether.And this isn't a question we can answer: each assembler is specific to a processor type - or even...
17 Aug 2019 by honey the codewitch
Using PCK's grammar system, and understanding the concepts behind it
26 May 2021 by Patrick P. Frey
In this article we see how a very primitive compiler is written in Lua using Mewa and how to compile and run a simple demo program in the shell.
28 Oct 2021 by Pete O'Hanlon
More in-depth look at classes, how to add our own constructors and change whether or not code outside our class can see our fields
28 Apr 2010 by User 583852
When performing division by a constant that is a multiple of 2 we can optimise the operation by performing a right shift.eg i = i >> 3;is equivalent to i = i / 8;My questions are:* Is there likely to be a tangible benefit to doing this or would a compiler (gcc in my case)...
3 Jun 2010 by M. Mohsen
Global variables are stored on the heap and local variables are stored on the stack.Objects created by the new keyword are stored on the heap because they will stay their for an indefinite time.Pointer created in a function are stored on the stack while the objects or memory blocks they...
3 Jun 2010 by Aescleal
At the risk of sounding like the daft paper clip that used to give you advice in Microsoft Office..."Hey, it looks like you want to access a structure field through a pointer and offset..."In C you're forced to use something that's got loads of casts in it - there was an example of how...
7 Dec 2010 by Andrew Phillips
This is a large topic and there are many considerations. For example, at one extreme you can have one executable and use run-time flags to control which features are seen. At the other extreme you can create different release configurations (see below) that define macros (for conditional...
25 Apr 2011 by Tarakeshwar Reddy
thexcodec wrote I want to program my own OS, from scratchLooks like you are on the right track ;). I started of with the same aim and as time passed I realised that I did not need a new OS (you could be different and end up writing one), but I did learn a lot of stuff which made me a good...
27 Nov 2011 by Nickos_me
Interesting articles can be found in this blog[^].Also you can read this[^].And in this[^] question you can find a huuuuuge count of links to articles.
27 Nov 2011 by CPallini
You may split your learning task in two fields:How to build a compiler (there are many many books about).Gain a deep knowledge of the programming language used to actually build the compiler (and, again, there are many many books on C# programming language).You may also find useful a tool...
31 May 2012 by Aescleal
There's only been one person in the history of mankind to have built a C++ compiler single handed, Walter Bright [1]. So I wouldn't even try yourself. He wrote a C compiler, saw a copy of the C++ Annotated Reference Manual, said "how hard can this be?". A couple of years later he'd found out how...
3 Jul 2012 by enhzflep
Nope. No can do.MS compiler produces .lib files, GCC produces .a files.You can't link .a files to projects with Visual Studio. Nor an you link .lib files to projects with GCC.What you trying to do/achieve?
28 Dec 2012 by Richard MacCutchan
Most compilers use a preprocessor to read the included headers and then convert all references, macros etc. into their final form. The converted output of the preprocessor is then fed into the compiler for conversion to object code. There are quite a few free tools available on the internet to...
28 Dec 2012 by Andreas Gieriet
If you want to parse and process any language, you probably need to read some text books first.E.g. C-Programming Language[^], or C11 Language Draft[^], etc.E.g. the latter specifies the #include semantics as follows:[...]6.10.2 Source file inclusionConstraintsA #include...
29 May 2013 by OriginalGriff
Probably Visual Studio - it is free (in the express editions) and it has a very similar look and feel throughout, regardless of the language you are using. If you have been developing in Eclipse for your Java, then you will probably hate going back to it...
5 Aug 2013 by User 59241
Quote:error LNK2001: unresolved external symbolTells you immediately that the linker cannot find this symbol in any library. You most likely have not included the required boost library in your project.See this link for "Using Boost libraries"Building Boost libraries for Visual...
11 Sep 2013 by Dave Kreskowiak
Considering the resources are compiled into the running .EXE, you can't modify them. The .EXE file is locked and cannot be modified while the .EXE is running.Another problem you have is that, under Windows Vista, 7 and 8, the Program Files folder your application is installed to is ReadOnly...
16 Sep 2013 by CHill60
There are some comments to this post[^] that will point you in the right direction - specifically a couple of good books on compiler design.Designing an Operating System and designing a Compiler are two very different things and not at all related in the way that you suggest ... it's not...
22 Nov 2013 by OriginalGriff
In practice? No, not in release versions - the intermediate variable will be optimised out.In debug versions there is likely to be a difference as debug versions generally do not employ as aggressive optimisations, if it uses any at all.You can check for yourself: this explains how to view...
22 Nov 2013 by Ron Beyer
Compile it and see!You can easily compare compiled exe's using ildasm (Intermediate Language Disassembler) that is included with Visual Studio. Also another fun trick is to compare two of exactly the same programs, one compiled for Debug, and the other compiled for Release.As far as...
13 Apr 2014 by Sergey Alexandrovich Kryukov
This is easier than with the languages targeting native platform, because you would need to generate machine code. With .NET, there is no machine code. You can parse code and translate it to CodeDOM. Please see:http://msdn.microsoft.com/en-us/library/y2k85ax6%28v=vs.110%29.aspx[^].In other...
22 Feb 2017 by Jochen Arndt
iostream is a C++ header file that should be installed by your compiler suite (usually in a sub directory of the compiler suite directory named include).When compiling source files, the compiler will check specific directories to locate include files. These directories must be configured in...
14 Aug 2019 by honey the codewitch
An LALR(1) parsing algorithm as part of Pck
29 Sep 2019 by Richard MacCutchan
See fibonacci sequence - Google Search[^]
5 Nov 2019 by Stefan_Lang
I strongly suspect this is a bug in the compiler's code optimization: M isn't read by the program, so the compiler will try to eliminate code referring to it - maybe it messed up this optimization because the statement cin>>N>>M internally translates into a nested function call:...
24 Apr 2021 by Aghast (nj)
Command (1) compiles the .c file to a .o (object) file, then stops. Command (2) compiles the .c file to an object file, then links the object file with the C standard library to produce an executable file named file. Both commands drop their...
13 Jan 2022 by Richard Deeming
This is part of the (relatively-new) "nullable reference types" feature: Nullable reference types | Microsoft Docs[^] When enabled, the compiler assumes that any reference type must not contain null unless it is marked as "nullable" by appending...
13 Jan 2022 by Afzaal Ahmad Zeeshan
This kind of question can easily be answered with a quick Google search. But, I would like to ask you why you want to do it? Python is an open-source programming language and is actively contributed to. If you wish to contribute, visit Python...
9 Apr 2010 by Ankur\m/
28 Apr 2010 by Arindam Tewary
When you write bitwise shift operation equivalent microoperation takes only one micro-operation to be performed by the ALU(CPU). It takes binary representation of the value supplied and performs a single "shift" micro operation.But when you write a division(float) it is converted into either...
31 May 2010 by Yuvaraj Gogoi
Hi,In C++ dynamic polymorphism (virtual) is implemented by vptr and vtables. In the same line, can I know how explicit keyword (used for constructor and copy constructor) is implemented?Yuvaraj
8 Jun 2010 by Aescleal
The only time structure padding (and alignment) is important is if you're generating data that is transferred to something that makes different assumptions about the padding.So if you have memory mapped hardware you might get a surprise if you naively map a structure over the hardware's base...
7 Dec 2010 by Rajesh G Manwani from Mumbai
Hi,I am developing ActiveX control using VC++ with Visual Studio 2010, on WindowsXP.I want to have multiple release types for my project. The release types will differ in features. The release A may have only features A1...An while Release B may have only features B1....Bn. Also, there...
7 Dec 2010 by #realJSOP
Macros are compile-time features, not runtime features.One way to accomplish this would be to include one or more DLLs in your project that turn one various features, and then base those features' availablity on the presence or absence of the DLLs. Of course, there are many other ways,...
7 Dec 2010 by ShilpiP
One way is like that:a) Create One Function InitializeComponent(Key)// Key is passed as argument.For Different client, the key is different For Client 'A' it is 3123123For Client 'B' it is 2343454b)Client must use this function.c) Check the key value is correct.c)...
20 Dec 2010 by Rajesh G Manwani from Mumbai
I updated an interface of an ActiveX control with two methods. I compiled the .idl file and generated the ocx. The interface had 89 methods. I got the following warning which I ignored:warning MIDL2362: too many methods in the interface, requires Windows NT 4.0 SP3 or greaterI am compiling...
7 Feb 2011 by creizlein
Looks like no one knows of an elegant or accurate solution, but i have come with an approach, that might not be bright, but at least seems to be accurate, somehow. and i decided to share it with everyone.According to my researches, .NET native images are identified, in a partial way, by the...
19 May 2011 by Albert Holguin
operator new will return a pointer to an object, so you need to give it a pointer to store it to:CClass *myClass = new CClass();since you're allocating this on the heap, you will need to deallocate by hand so you don't have memory leaks:delete myClass;
15 Jun 2011 by krmed
If this code is in a file ending in .c, then the answer is that all variables must be declared before any code.If the file is .cpp, then this error doesn't make sense, however I would expect a warning for unreachable code since main will return before the code.
15 Jun 2011 by Chuck O'Toole
"C" does not have "bool", "true" or "false". "C++" does have them (as does "C#") as recognizable data types. The Visual Studio IDE editor highlights "bool", "true", and "false" in blue because it does recognize them as language keywords and even does that in files with the ".C" file...
21 Jun 2011 by TRK3
Try this link instead:http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/4a1c9610-fa41-45f6-ad39-c9f6795be6f2/[^]From that discussion it appears to be an issue of linking in a library that was either compiled with an earlier version of VS or which expects to link to the CRT...
18 Jul 2011 by Espen Harlinn
If I remember correctly Derby[^] uses JavaCC.Best regardsEspen Harlinn
9 Aug 2011 by Sergey Alexandrovich Kryukov
As I understand it, the output means output the text to console (if it's is too file, it's trivial, is somewhere else, it would be uncertain); you only need to run some application writing to console under control of your C# application and compare output with some preset data.Is it for...
27 Nov 2011 by Anuja Pawar Indore
Refer this threadhttp://stackoverflow.com/questions/821086/resources-for-writing-a-c-sharp-compiler-for-class[^]
28 Feb 2012 by enhzflep
http://www.google.com.au/search?q=open+source+cross-compiler[^]
25 Apr 2012 by OriginalGriff
It's possible, yes - just about everything is - but that doesn't mean it's easy. It isn't, particularly.There is no direct way to do it: there are two options I can think of.1) Access the executable file that started the program at run time and pick up the CreateTime from that. This...
27 Sep 2012 by ekolis
Usually, when someone in closed-source land has a really good idea and implements it well, the folks in open-source land try and replicate it to the best of their ability. .NET? Mono. Photoshop? GIMP. Mac OS? GNOME. So why is it that only Microsoft compilers support #pragma once? Did Microsoft...
10 Mar 2013 by Albert Holguin
When you use an external library, you have to include the lib file and dll (if dynamic, lib only if static). The header simply has the definitions but the compiled functions are inside the library file which is needed by the linker.See...
3 Apr 2013 by nv3
Visual Studio has a special type of project, called Makefile Project, that allows you to use your own make file and other command line tools to build your project. SeeMSDN VisualStudio 2005 Makefile Project[^]In such a project you can use for example Microsofts version of the make...
3 Apr 2013 by CPallini
From the documentation[^]:The Windows SDK no longer ships with a complete command-line build environment. You must install a compiler and build environment separately. If you require a complete development environment that includes compilers and a build environment, you can download Visual...
3 Apr 2013 by Richard MacCutchan
The SDK merely contains the support libraries, so you will need a compiler and linker to build your code. If you do not already have copies then Visual C++ Express contains all the tools you need.
29 May 2013 by pasztorpisti
For C++ Visual Studio equipped with a few plugins is unbeatable (plugins VAssistX, and I like the extended scrollbar of Productivity Powertools). I share the opinion of OriginalGriff about moving from Java+Eclipse to C++ and Visual Studio. C++ is hard to parse (C macros and other ugly stuff) and...
17 Aug 2013 by Ron Beyer
While it is possible to do, I don't believe anybody has written a C/C++/Java compiler in VB.NET or C#. Writing a compiler is quite an undertaking, if you are wanting to go down that road then I would suggest learning ANTLR[^]. However due to the question itself, I'm pretty sure that this may...
11 Sep 2013 by Sergey Alexandrovich Kryukov
tasinsahin wrote:I read that assemblies could be modified on runtime.You can modify the assembly only if its modules are not currently loaded.None of the loaded Windows executable modules can be modified.If the assembly is not loaded, it can be modified, but this is usually (or in almost...
11 Nov 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Instead ofDataTable dt;Write...DataTable dt = new DataTable();As you have not instantiated the DataTable object, that's why it is showing the error.
30 Nov 2013 by ianmartinez97
I am trying to create a program that will generate an executable based on user specified parameters that I add in as resources, but whenever I try to compile the program, all attempts to access the resources fail.In the program that will generate the EXE file, I have this code to compile the...
5 Dec 2013 by Yvan Rodrigues
I don't think this is possible, but I have always hoped it is. When you apply [Obsolete("You really shouldn't use this anymore.")] to a member, it causes the compiler to generate a warning or error, which then appears in the Error List in Visual Studio.It would be amazing to be able to...
5 Dec 2013 by CHill60
Micro$oft have a How-to for that :-)http://msdn.microsoft.com/en-us/library/zzszcehe.aspx[^]
19 Dec 2013 by Sergey Alexandrovich Kryukov
You can use some available assembler: http://en.wikipedia.org/wiki/Assembler_%28computing%29#Assembler[^].This can be done using System.Diagnostics.Process.Start:System.Diagnostics.Process.Start(@"a\file\path\to\the\executable\module\of\some\Assember", "some parameters...
17 Mar 2014 by Sergey Alexandrovich Kryukov
Please see my comment to the question.I don't clearly understand why would you really need what you need, but I would suggest to think at one alternative: using "regular" VB.NET and C# compilers available on your host system. They are available simply because you are using ASP.NET, which, in...
28 Apr 2014 by thatraja
Google gave me sites like http://regexlib.com/[^], browse thereORCreate yourself. Check theseExpresso - A Tool for Building and Testing Regular Expressions[^]The 30 Minute Regex Tutorial[^]
25 May 2014 by OriginalGriff
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...A very quick search gave over 7 million hits: Google[^]In future, please try to do at least basic research yourself, and not waste your time or ours.
20 Nov 2014 by Maciej Los
The basic infromation about lexical analysis, tyou'll find here: http://en.wikipedia.org/wiki/Lexical_analysis[^]http://en.wikibooks.org/wiki/Compiler_Construction/Lexical_analysis[^]http://www.javaworld.com/article/2076874/learn-java/lexical-analysis-and-java--part-1.html[^]Sample code:...
1 Apr 2015 by Thomas Daniels
Take a look here:http://stackoverflow.com/questions/1669/learning-to-write-a-compiler[^]
1 Apr 2015 by CHill60
Not something that can be answered in a "Quick answers" forum!However similar assignments have been set before - see the responses to this post Where I Have To Start Building A Compiler?[^]
26 Apr 2015 by OriginalGriff
That's because it's compiler output - and it doesn't know what the code means! So it uses it's "generic" parameter passing mechanism - via the stack - to hand the const string to a function which can do the printing instead of "knowing" what you are trying to do and just producing code for...
26 Apr 2015 by Frankie-C
EMU8086 is an emulator, assembler,...etc. for 8086 16bits code only. It emulates old 16 bits DOS OS. Specifically the code you used starting with an ORiGin metainstruction denotes the writing of a binary '.com' executable (by default located at adrress 0x100). To print out characters you use DOS...
26 Apr 2015 by Frankie-C
If you really want use a compiler to generate assembler listing to reuse in your code you have to understand that you need a DOS C compiler, not a 32/64bits compiler like GCC.If you really want go on download the free version of TURBOC 2.01 that is widly available around. You'll find it...
20 Aug 2015 by Sergey Alexandrovich Kryukov
It's something likeconst StructType * myVar1 = reinterpret_cast(0xA000);// ...Also, you can face some problems with alignment of separate members withing your struct and possibility of padding the memory in structure with unused memory fragments, for the sake of access...
3 Oct 2015 by Jochen Arndt
The errors are in the lines 546, 547, 548, 584, and 586 of SharedMemory.cpp where you are using the variable mxArray_tag. The type of that variable seems to be defined in line 83 of the include file SharedMemory.hpp.See the MSDN error description for the errors (press F1 when the error...