1

I am looking for a way to compile a small computation-intensive program to a machine code executable.

The program is currently written in the Microsoft Visual Studio C# environment, but I am just as happy to do it in C, C++ or any similar variant if it results in my getting a machine code executable.

(I also have the SharpDevelop environment)

I want to avoid the run-time overhead that I expect is incurred by the using a run-time JIT compiler.

I expect that only I will ever use the program and probably only on my machine(s), so I do not have worry about deployment considerations.

Lt Kije
  • 23
  • 2
  • 1
    What do you mean? Of course C and C++ compile to machine code. – OldProgrammer Nov 23 '14 at 23:13
  • Previously asked / answered here if you are asking for assembler output to look at. http://stackoverflow.com/questions/840321/how-can-i-see-the-assembly-code-for-a-c-program – Weather Vane Nov 23 '14 at 23:16
  • 2
    All the compilers you mention create programs that execute machine code. The exact moment in time that the machine code is generated is just different. With C# having multiple options to determine exactly when. Using the jitter can be the fastest way. And if it is not then you use ngen.exe to generate the machine code ahead of time. Or use .NET Native which uses the C++ compiler's back-end, probably not in the cards when you don't want to share. So it doesn't really matter and you'd only care how much time you spend on your machine cycles. The ones between your ears. – Hans Passant Nov 23 '14 at 23:18
  • With a tip of the hat to OldProgrammer, Hans, Jeff D. I am a VeryOldLapsedProgrammer and recently returned. When Using C# it was clear the that Build produced IL that was in turn JIT'ed at runtime. Not what I am after at all. If C++ builds (compiles&links) to a machine code executable, than I am happy. Kije. – Lt Kije Nov 23 '14 at 23:53

1 Answers1

0

All C/C++ compilers compile to native machine code, that's why you can directly address memory, have inline assembler, and care about sizeof(int) on the system you are compiling for.

Jeff D.
  • 328
  • 1
  • 7
  • 1
    There do exist the occasional C++ interpreter. – 2785528 Nov 24 '14 at 00:15
  • Other than as experimental toys, what purpose would a C++ interpereter have ? You really think that's worth a down vote ? – Jeff D. Nov 24 '14 at 06:44
  • (Not my downvote) Untrue apparently, MSVC++ seems to have the ability to compile ordinary C++ code (such as Hello, World) to .Net. In that case, you cannot directly address memory or have inline assembler. (And in general it's all Undefined Behavior) – MSalters Nov 24 '14 at 11:06
  • FYI, you sure *can* directly access memory from .NET (C# has pointers), or get the value of `sizeof(int)`. Inline assembly is available in a mixed-mode dll (using C++/CLI with a native C++ section). – Lucas Trzesniewski Nov 24 '14 at 12:05
  • @JeffD. - Not my downvote. – 2785528 Nov 24 '14 at 22:54