Pseudocode Translation - c++

I started working just a few hours ago on a pseudocode translator, which will translate a specific pseudocode, reguarding work with stacks and queues, to c/c++ executable code. The translator has education propuses.
I am still designing the project.
I've started thinking about how this could be done; I figured that maybe the best way to do this is to, in the first place, analize the pseudocode, change it to make it c/c++ code and then compiling it to make it an exe.
NOW, this would mean that the client machine SHOULD HAVE a c/c++ compiler installed on it.
As I'm working with .NET clases ( System.Collections.Generic.Queue(Of T) and System.Collections.Generic.Stack(Of T) ), I thought that a solution to this would be to use the same compiler visual studio uses to compile c/c++ code.
I've been investigating about this proccess, and as far as I know, the only way to compile c/c++ code by using a visual studio tool, is executing cl.exe from the Visual Studio Command Prompt. I found that information here at MSDN (article about how to manually compiling a c/c++ program)
So my first question is: does the USER versión of .NET Framework (this means, assuming the user DOES NOT have Visual Studio) include a c/c++ compiler? If yes, is it the same included in visual studio, cl.exe? How can I get access to it? If no, is there a free compiler WITHOUT IDE I can include on my translator setup?
Notice that here we're talking about transforming a pseudocode string to executable c/c++ code here, the output string MUST BE COMPILED FROM THE USER PC, that's what the project is about.

There is no compiler included in the .Net framework - it is for running binary files produced by the compiler.
It's possible to get the compiler for free through for example the Visual Studio Express free download scheme. There are some license limitations on that ("no commercial use", if I remember correctly - so that would mean that if one of your customers uses your product, they can no sell the resulting code they have produced [and still be within the contract with MS]). Unfortunately, this isn't "without IDE", but the compiler that is part of the download is usable without the IDE, so if "without IDE" is simply that you want to be able to run the compiler with your program, then it will work.
If you really need a package that contains the compiler (in .Net variant) but no IDE code, then you will have to find a different solution - and for .Net I'm not sure there is one. The DDK (Device Driver Kit) contains the native C and C++ compilers. But it won't, as far as I understand, produce .Net code [I could be wrong].
Edit: It seems like if you are writing your own code, you can compile it using CSharpCodeProvider - however, this is not the same as a command-line compiler of cl.exe.

The long, the short, and the ugly is "no". The only C++ compiler remotely suitable for inclusion as a library is Clang, it's free and not toooooo bad to work with, and you'll have to write your own .NET binding, and don't forget to have fun with providing your own linker and stdlib.

Related

LLVM 3.4 integration with VS 2012

I have read online documentations and built LLVM using Cmake and visual studio using Getting Started with the LLVM System using Microsoft Visual Studio. I could not find how to use the LLVM tooolchain on an existing visual studio project. I am new to this environment and would appreciate any help.
EDIT 1 : I am contributing to a project, where I am required to build an Interpreter. The project restricts me to code in VS.
Here are the errors when I try to integrate LLVM and VS, I must be doing something terribly wrong LLVM compilation errors on VS 2012
EDIT 2: I am unclear as to how should we integrate LLVM in an existing VS project after a successful LLVM build (and installation on system).
EDIT 3: I aim to develop my own language utilizing clang/llvm. I cant figure out how to do this sitting in the VS enironment.
The instructions you have followed are not supposed to produce a "plug-in replacement for Visual Studio's provided compiler", but a way to, generally, build LLVM+CLANG - and of course, unless you are wanting to spend a lot of work [1], to build a compiler written in C++, you need an existing C++ compiler - and the instructions show how to do that with Visual Studio. You then have a clang and clang++ compiler and tools on your system, but it's not meant for "use it within Visual Studio".
From what I can tell from past experience, the Visual Studio compiler is not trivially replaceable, but you can of course use a Makefile Project to compile anything in any way you like.
This discussion from MS does provide another solution, but again, it's not a "instant plug in" solution:
http://social.msdn.microsoft.com/forums/vstudio/en-US/b9610ed2-e8ae-48c9-864c-e3d12af97b05/support-an-alternative-compiler
Some further googling shows this up:
https://github.com/ishani/ClangVSx
I have no idea if that works well or not - it seems to "only" support clang 3.3, where the current release is 3.4 and the "latest" is pre-3.5. I doubt there's a huge amount of difference, but I'm also not sure that there's "no difference".
[1] You can "bootstrap" a compiler from nothing, but it's really quite a lot of work writing a small compiler that can do a subset of the language, repeat this several times, to eventually compile the actual compiler in a more full compiler - and LLVM is not even nearly designed for that in the first place.

How to Compile and Debug C++ in Notepad++ using Turbo C++ Compiler

I have installed NppExecute plugin in notepad++. I am not able to figure out next step to compile and debug C,C++ programs in Notepad++.
System Details: (a) Turbo C directory C:\TC (b) OS Windows 7
Please provide complete details on how to set Environment Variable and Scripts for Compiling and Debugging.
Notepad++ has the run feature, but as far as I know it's unable to help you debugging (e.g. stepping through code, watching variables, etc.).
Your best bet would be using a simple batch file to compile the code and run your debug commands, but as far as I know you can't include everything into Notepad++ (i.e. it's no real C/C++ IDE).
Only option you've got is adding the created batch file as the program to be run by NppExecute.
Edit:
Overall, as rkosegi suggested, if possible, use a more up-to-date toolchain.
Microsoft's Visual C++ Express Edition can be downloaded for free and used for private or commercial projects.
If you target cross platform code, it might be easier to use MinGW to use GCC/G++ under Windows.
I wondering why somone wants to use turbo C++.If you run Windows, just use Visual Studio Express, or Dev-C++.If you still want to use Turbo C you will run into several problems with compatibility of this ancient software.

Using Visual C++ with a different C++ compiler?

I like the Visual Studio IDE. I'm used to it and find it is the best IDE I've ever tried. We also find increasing use of C#/.NET here.
However, after the underwhelming announcement regarding C++11 features in VS11 I'm looking into replacing the compiler.
It seems that the Intel compiler fully integrates with VS but that doesn't mean it will compile our Windows code. I don't know how I'd fare with a try of g++ or clang
Can VS actually be productively used with a different C++ compiler to compile Windows code, that is legacy code using all kinds of Win32 / MFC / COM stuff?
Depends on how much use you made of the Microsoft-proprietary extensions. Things like #pragma once tend to be supported by all the major compilers, but the weirder COM things (e.g., #import and anything C++/CLI) probably won't be. No idea if MFC will build under the new compiler, but you'll probably have to link it statically or ship your own DLL; G++ definitely uses a different mangling scheme than MSVC.
I'm not sure how easy it is to replace cl.exe and keep your vcproj files intact (though some compilers actually do it), but there are always Makefile projects.
I have never actually worked with the Intel C++ compiler, but I see no reason why it wouldn't compile the code that VC++ does. Here is official Intel documentation.
I use Visual Studio 2008 with a Makefile project to cross-compile; no reason you couldn't do the same with a different Windows compiler.

How do you try out small/simple C or C++ source codes?

It is very easy on Linux to fire-up vi and write a 100-200 lines of code, compile and see the results: ie. Trying small simple examples of C/C++ code.
On windows however, I like Visual Studio but to use it you have create a new solution then a project which then creates a new folder, generates very large PDB and caching files and a small example of 100-200 LOC becomes a 20Mb large project(?!) after compilation.
So the question is how do you write this kind of small codes on Windows? Possibly Cygwin or Dev-C++ (which is not active since 2004?).
You can compile from the command line using cl.exe. See the MSDN article How to: Compile a Native C++ Program from the Command Line for detailed instructions.
When you installed Visual Studio it created an entry in your programs named something like "Visual Studio Command Prompt" (maybe in a group "Visual Studio Tools").
Execute that Command Prompt (it sets up some environment variables needed for the command line compiler) and use cl, the command line compiler.
> cl /?
Copyright (C) Microsoft Corporation. All rights reserved.
C/C++ COMPILER OPTIONS
-OPTIMIZATION-
/O1 minimize space /O2 maximize speed
/Ob<n> inline expansion (default n=0) /Od disable optimizations (default)
/Og enable global optimization /Oi[-] enable intrinsic functions
...
Edit -- copy from another answer :)
Microsoft Documentation: VS2005, VS2008
For the simplest examples codepad may be an option.
I think there's nothing wrong with firing up Visual Studio for some testing. You can delete the 20MB afterwards ;)
However, you can also just invoke the command line compiler on Windows. Just start a Windows SDK console (or Visual Studio console) and you're there. And you can even use vi (need to install it first, of course).
I always use MinGW (GCC for windows) for such tasks.
MinGW is a good solution if you're not using anything Visual Studio specific. If you are, in the start menu with Visual Studio, there should be a script that starts a "commandline" for visual studio.
Also, please keep in mind, even if you aren't going to use Visual Studio, if you use MinGW, you're going to run into issues even with things you might not expect (like...if you decide to try the Apple Bonjour SDK, in which case you're going to get nasty link errors) because GCC and MSVC++ libraries don't always play nice.
And if you don't have access to your local computer, or you are to lazy to look for command line compiler you can paste your code to on-line compiler. There are several of them on the net you can try one of them here. It's free, no registration needed. It has some flaws but for quick code check it's just fine.
You can also use some other languages, C, C++, D, Haskell, Lua, OCaml, PHP, Perl, Python, Ruby, Scheme, Tcl to be precise.
Maybe I'm just a *nix geek, but I went on over to http://consoletelnet.sourceforge.net/gccwin32.html and got gcc for win32. I then headed over to http://unxutils.sourceforge.net/ and go these command line tools. (I renamed their find.exe to gfind.exe to avoid conflict with windows find). I then use gvim for win32 to write code and make/gcc to compile it. Now I only have to learn one environment.
For small bits of code I want to test, such as code that I'm going to include in an SO answer, I always use the command line. My tools on Windows are:
the MSYS tools, particularly their bash shell
the vim editor
the MinGW GCC compiler (Twilight Dragon branch)
I haven't used any of them, but MinGW and lcc-win32 seem to be pretty lightweight, and people seem to like them in news:comp.lang.c. MinGW is a port of GNU Compiler Collection for Windows and is free, lcc-win32 is free for non-commercial use.
You can do the exact same thing for Windows -- fire up VI and run the output through gcc.
Either get MingGW/MSys, Cygwin, or native ports of each app (gnu tools, vi)
Just because you're using Windows, doesn't mean you're forced to use Visual Studio.
I've got a Visual Studio test project with a main file I just overwrite every time I want to test something new. The couple of MB taken up by the .ncb file really really really doesn't matter. A bigger issues is the need to create a project. But I get around that by reusing an old test project.
For small/simple C or C++ source codes I use Ideone. It supports over 40 programming languages.
I usually edit my code within notepad++ then compile it with gcc under cygwin or msys.
I have used Dev-C++ post 2004, and it still works quite well.
I even used projects coded in Dev-C++ for my practicals that had to run on machines using Linux. Just changed the make files.
I also use Visual Studio; for quick testing and prototyping, I have a file scratch.c on my desktop, which I just load up and test things out in.
I don't see opening Visual Studio, clicking the new document icon, writing code, pressing F5 then just accepting the defaults for everything as being too much effort :)
The other alternative I have (which I don't use for C, but do for Haskell) is to PuTTY into a Linux box I have access to, and do everything on there.
I have a Test.sln which has a Test.vcproj which has a Test.cpp. The solution has a few handy configurations (for maximum C++ std conformance and others). I just paste code into/from the Test.cpp file and compile it that way.
I use cl.exe and nmake.exe from Visual C++ Express to compile small groups of .c and .cpp files. Rolling your own simple Makefile for nmake.exe is easy.

C on Visual Studio [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm trying to learn C. As a C# developer, my IDE is Visual Studio. I've heard this is a good environment for C/C++ development. However, it seems no matter what little thing I try to do, intuition fails me. Can someone give good resources for how to either:
learn the ins and out of C in Visual Studio
recommend a better C IDE + compiler
Edit: See also: https://stackoverflow.com/questions/951516/a-good-c-ide
well you can use visual studio just fine take a look at here man
http://www.daniweb.com/forums/thread16256.html
Go to View Menu select Solution Explorer or CTRL+ ALT +L
Then Select The project that your are developing and right click on that.
Then select the Properties from the submenu.
Then select the Configuration properties from the Tree structure. under that select C/C++ then select Advanced. Now in the right side pane change the property
Compile As from Compile as C++ Code (/TP) to Compile as C Code (/TC)
Finally change your file extensions to .c
Now you configured you Visual Studio to compile C programs
And you can use NetBeans too it could even be more user friendly than Visual Studio download it you wont regret i promise
The problem with learning C within Visual Studio is that you are compiling C using the Visual Studio C++ compiler. You might want to try learning C using the GNU GCC compiler from within the Cygwin environment in Windows.
Answering the purely subject question "recommend me a better C IDE and compiler" I find Ming32w and Code::blocks (now with combined installer) very useful on windows but YMMV as you are obviously used to the MS IDE and are just struggling with C.
May I suggest you concentrate on console applications to get a feel for the language first before you attempt to tie it together with a windows UI which in my experience is the hardest bit of windows development.
Simple and sweet: Console applications (basic C programs using printf and such) are easily and cheaply done with the Tiny C Compiler - a no frills, no gui, complete C complier.
http://bellard.org/tcc/
However, C development is relatively simple on Visual Studio as well. The following instructions will set Visual C++ up as a good C compiler, and it will produce console applications at first, and yo can move up into more complex windows apps as you go.
Get the Visual Studio C++ edition (express is fine)
Start a new project - disable pre-compiled headers (maybe the wizard will let you do this, maybe you'll have to change the compiler settings once inside the project)
Delete everything inside the project.
Create a new "example.c" file with the hello world example
Compile and away you go.
Alternately, get a linux virtual machine, or Cygwin. But as you already have Visual Studio, you might as well stick with what you know.
As an aside, this isn't Atwood learning C finally, is it? No ALTs! ;-D
-Adam
Bloodshed Dev-C++ is the best windows C/C++ IDE IMO: http://www.bloodshed.net/
It uses the GNU compiler set and is free as in beer.
EDIT: the download page for the IDE is here: http://www.bloodshed.net/dev/devcpp.html
As already said, you should check out the VS.net C++ edition, but if you'd like to try something else Eclipse has a C++ edition. You can get more info from http://eclipse.org or check out the distro at http://www.easyeclipse.org/site/distributions/cplusplus.html
The problem with learning C within Visual Studio is that you are compiling C
using the Visual Studio C++ compiler. You might want to try learning C using
the GNU GCC compiler from within the Cygwin environment in Windows.
This is a legitimate response, I posted an IDE that uses the GNU compilers, so why has he been down modded?
This is the type of thing that will make me not use SO, why down mod someone just because they are recommending a different compiler, and IMHO, a better one then Microsoft's?
get real people, and #Antonio Haley I gave you +1
http://xoax.net/comp/cpp/console/Lesson0.php
Any use?
Some people say that a smaller IDE is better for learning. Take a look at Code::Blocks. It's generally true that beginning C in an IDE is hard because not many books explain enough to control the IDE. Perhaps starting in a console and a basic text editor with syntax highlighting would be better – at least under Linux. Since Windows' console is far from great, I'd not recommend using it.
/EDIT: Dev-C++ used to be the best freely available IDE for Windows. However, it's development has been discontinued years ago and the most recent version unfortunately is full of bugs.
There's a very good reason to learn C and C++. The reason is that there's a lot of C and C++ code out there that are performing very real and important tasks. Someone who considers themselves a programmer and a learner(doubtful that you can separate the two) can learn a lot from these lines of code.
You can learn a lot from each language by studying the other, but if you really want to grok C it's a lot easier to separate yourself from anything C++ for a while. Visual C++ is great but GCC is a great way to thrust yourself into vanilla ANSI C without having to mentally sidestep any C++.
#mmattax thanks!
C in Visual Studio is fine, just use the command line compiler that is included in the Pro edition. Yes its the C++ compiler but treats all files ending .c as C . You can even force it to treat ALL files as C with a switch. The VS documentation has entries on it, just search the index for Visual C.
Visual Studio is one of the best IDEs for C/C++.
I don't think it is complicated and hard to use - if you have questions about it - ask them.
Some other compilers/IDEs are fine too, but if already have Visual Studio and have used it - why not stick to it?
For plain C, I suggest Pelles C. Generates optimized code and supports C99 constructs.
Features:
Support for 32-bit Windows (X86),
64-bit Windows (X64), and Windows Mobile (ARM). Support for the C99 standard.
Integrated source code editor with call tips and symbol browsing. Integrated source-level
debugger. Project management.
Inline assembler for X86 and ARM.
Integrated resource editor. Integrated bitmap, icon and cursor editor. Integrated
animated cursor and video editor.
Integrated hex-dump editor.
Supportfor custom controls in the dialog editor. Support for custom project wizards.
http://www.smorgasbordet.com/pellesc/
When i used visual studio 5.0 it should compile c code as long as the header files and lib. are there for the compiler to find. In fact most C++ compilers like G++ will compile C code just fine. But i'm not sure how well.. If you are targeting a platform then you can change the header files and lib. within you IDE and Compiler.
Visual Studio has a great debugger that no other Compiler that i have seen can compete with. I have been using gcc darwin10 4.2.1 and find the debugger is basically just the one you can getfree with any linux flavor. I recommend you learn both on a plain vanilla gcc compiler and also try visual studio which costs money. The express edition does not allow the use of threading and several other things that I forgot about. Visual Studio 5.0 should be ok to use and the debugger is much more human friendly then the one commandline version called GDB. Try DDD on linux which is similar to XCODE's debugger.
Although C++ and C are different you can compile both together. But you should understand each ones flaws and good points. C code is faster, but C++ is much easier to write and manage larger code. C++ is object oriented but C is procedural while they are both imperative languages. I would suggest learning objective-C since you can use both C++ and C libraries. Using the features you like in all three languages!!!
Visual Studio or Express do consider .c files as C code, but the compiler will keep giving warnings, and irritating suggestions which you do not require, in the debugger. Gives an indication that Visual C++, as the name suggests is optimized for C++ development for the Windows Operating system, which was originally written in plain pure C.