Using Visual Studio as GCC project editor (?)
Rayman
Posts: 14,826
GCC crew may take offense, but I'm used to working in Visual Studio...
So, I just took a stab at seeing if I can use Visual Studio to edit Prop GCC code...
One cool thing I just found googling to this page:
http://www.c-sharpcorner.com/uploadfile/rmcochran/running-the-command-prompt-from-visual-studio-tools-menu/
is adding an external tool to the "Tools" menu like this:
I'm pretty sure this is going to work because I just happened to have "calc.c" open (from the demos) when I tried it.
I thought I was going to have to create a "build.bat" file, but it turned out (to my surprise) that one already existed:
Not only did it compile, but it tried to load too.
So, I just took a stab at seeing if I can use Visual Studio to edit Prop GCC code...
One cool thing I just found googling to this page:
http://www.c-sharpcorner.com/uploadfile/rmcochran/running-the-command-prompt-from-visual-studio-tools-menu/
is adding an external tool to the "Tools" menu like this:
I'm pretty sure this is going to work because I just happened to have "calc.c" open (from the demos) when I tried it.
I thought I was going to have to create a "build.bat" file, but it turned out (to my surprise) that one already existed:
Not only did it compile, but it tried to load too.
Comments
So many things coming together at the moment. I'm playing around with translating the object description file for C# into spin. It is a bit complicated as it involves translating an object oriented language into a non object oriented one, but it is quite possible to do. But translating C# into C++ is more plausible, and I think averagejoe is very close with the cache driver for a touchscreen.
It would be nifty to be able to write and debug C# code on the PC prior to running the same code on the propeller. I can see several ways to do that.
Keep experimenting Rayman, this looks great!
There are several ways to do it apparently...
This page describes how to do it with the free Express version of VC++:
http://arduino.cc/playground/Code/VisualCPPExpress
The one thing that makes it work is a "Use External Editor" option in the Arduino IDE.
So, maybe adding this option to "Simple IDE" would let people do something similar...
On second thought, I like the way I did it earlier better.
It's nice to have all the files together in Visual Studio so I can search through all the project files...
Setting up a Visual Studio project for a Propeller project is certainly possible but it turns into a real hassle when you have big projects or you want to either offer your code to use by others, or you want to use code that others wrote.
The problem is that you have to change the compiler options for each and every .c file to use the Propeller compiler, and there's no easy way to do it automatically, so it gets tedious. Using a batch file (or even better: a make file) helps, but the bottom line is: to me it's only worth leaving SimpleIDE if I need to do something in the editor that SIDE won't do, or is bad at, like search and replace. And in most of those cases, I'd rather open the file in an editor such as Notepad++ than having to start Visual Studio.
===Jac
Ok, I tried out the forumists/jazzed calc example in Visual Studio and I think it works with some minor changes...
First, I had to disable use of precompiled headers in the project settings:
Attachment not found.
Second, I had to change unistd.h to Windows.h like this:
Then, had to change sleep to Sleep like this:
It then compiles and runs in a DOS window in full Debug mode with any breakpoints you want:
Attachment not found.
Since Visual Studio Express is a free download, this may offer people a way to test out and debug GCC code...
Automatic code completion, context sensitive help, find in files, are just a few.
Plus, I'm very used to the colors and other choices just don't look right to me...
Sharing with others not using Visual Studio is a problem though. Might not be a huge problem though.
BTW, if you read the first post, you can see how I compiled with PropGCC inside Visual Studio very easily...
I think what others in the thread are interested in is using Visual Studio as an IDE but compiling with PropGCC to produce a Propeller executable. That's possible, but it seems it's still awkward.
Eric
Try this link:
http://aeroquad.com/showthread.php?2170-Using-Visual-Studio-as-IDE
Cheers.
(later, I posted about how to run it in Windows because that's nice too...)
Batang, that looks like it might be a way to make this work even better...
I created a build.bat file and then set the "build command line" to "build".
Was also able to specify a PropGCC include path so that clicking on "propeller.h" opens it up...
As an added bonus, I can edit embedded bmp files in the editor. Although not many people are likely to use this feature...
Anyway, I think this is even better than that other way. Now, when I hit the green "Start" button, it compiles and then loads.
The interactive terminal mode option for the loader seems to mess up Visual Studio though... Have to look into that...
Build from the menu runs the build.bat file that runs propeller-elf-c++ and then propeller-elf-size to report the program size
The green run button now builds and then runs propeller-load.exe with options you can specify
Only slight issue left is getting intellisense to not put red squigglies all over...
Seems there are a lot of things that are not defined...
Main culprit is uint32_t, which it doesn't seem to know because neither _INT_SIZE nor _LONG_SIZE are defined...
Also it marks things like DIRB, waitcnt and cogstop as errors.
I think there, it doesn't know how to handle the definition:
extern _COGMEM volatile unsigned int _PAR __asm__("PAR");
So, I have to decide if I should define things myself, learn to ignore the squigglies, or find a way to get intellisense to ignore these perceived errors...
Squiggles are up to the language processor. Eclipse has similar issues, and needs a plugin to do the right thing.
The alternative to uint32_t is unsigned int or unsigned long on Propeller GCC, but not necessarily on other processors or compilers .... Want to change 1 line of code or 1000?
I can probably live with the other syntax problems if there's no easy solution...
Some things like PAR, waitcnt, etc... are just Propeller specific. Some VisualStudio thing will have to be tweaked to get around such issues.
Looks like _INT_SIZE is defined in compiler.h which is included in stdint.h .... propeller.h includes stdint.h. Given that, I'm not sure I understand the issue with _INT_SIZE.
I see in compiler.h that __GNUC__ must be defined by the gcc compiler that Visual Studio doesn't know about.
So, all I've done is use #if, #else, #endif defines to define things the way that don't get flagged as errors...
Did this in cog.h too and now the only squigglies I have are on waitcnt and cognew. But, I think I know how to fix those up too now...
_INT_SIZE is inside #ifdef __GNUC__, because (in theory) the sizes could be compiler dependent. I guess __GNUC__ is not defined inside Visual Studio. We could provide default sizes in compiler.h if no compiler symbols are recognized.
I have one code squiggly free now with this minor addition to compiler.h
and a similar thing in cog.h
command line tool that will build the project based on settings in a .side file.
The .side project files seem to have all the necessary info to build a project with...
The file is just plain text and I think I can decipher the format...
True. You can find out more about what SimpleIDE does with files in the UserGuide - you've probably seen that by now. There is also a BuildC class in the SimpleIDE repository that can be "ported" for making a stand-alone app.
See http://code.google.com/p/propside/source/browse/propside/buildc.cpp?name=spinside and http://code.google.com/p/propside/source/browse/propside/buildc.h?name=spinside
The BuildC class extends the abstract Build class http://code.google.com/p/propside/source/browse/propside/build.cpp?name=spinside and http://code.google.com/p/propside/source/browse/propside/build.h?name=spinside Unfortunately there are lots of hooks into the SimpleIDE infrastructure, but they should be easy to trim out.
There is another initiative I'm studying for Parallax to make SimpleIDE generate intermediate files that can be used in Visual Studio or other IDE's like Geany, Eclipse, Netbeans, etc.... It's part of a broader simplification effort. Once I have more concrete progress, I'll describe it all.