Visual Studio for development?
-
- Posts: 1
- Joined: Thu Jan 01, 2009 1:29 pm
Visual Studio for development?
Hello guys! I am relatively new to OS development... There's one question I would like to ask... I own the Visual Studio 2008 Professional edition since I've been programming C++, DirectX/Win32 applications, static, dynamic libs and such stuff.... I've been wondering about something and it's not clear to me... Since everyone recommend compilers such as DJGPP, I was wondering... Is it possible to develop parts (of course) of the OS within the Visual Studio's IDE... Of course, full native code, ANSI/ISO.
Thanks in advance!
Thanks in advance!
Re: Visual Studio for development?
It is possiblel to develop an OS on VS, even only with it. If you want to know more look here http://www.brokenthorn.com, there is a toturial how to make am OS with Visual Studio.
Re: Visual Studio for development?
There's also something about it on the wiki. Note that there are limitations to the VC++ compiler and linker (the COFF/PE output format limitation) and I believe there is some restriction about OS' in the MASM (Microsoft assembler which Visual Studio uses to assemble ASM files) license, but I'm not sure though.
If the compilers don't work out for you, remember that Visual Studio has a nice flexibility in rules. You could add your own build rules that use the MinGW compiler and linker with the NASM assembler for example. Another benefit is that you can set up Visual Studio with your OS so that you merely have to press the build button and your entire OS is built or the debug button to build your entire OS and start QEMU/Bochs with it for example.
If the compilers don't work out for you, remember that Visual Studio has a nice flexibility in rules. You could add your own build rules that use the MinGW compiler and linker with the NASM assembler for example. Another benefit is that you can set up Visual Studio with your OS so that you merely have to press the build button and your entire OS is built or the debug button to build your entire OS and start QEMU/Bochs with it for example.
Last edited by Creature on Fri Jan 02, 2009 5:04 am, edited 1 time in total.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Visual Studio for development?
There is a difference between the application used to compile your OS (generally cygwin), and the application used to write the code in (which can be anything, including Visual Studio)
Microsoft's compiler can be used for OS development, but it's not recommended.
Microsoft's compiler can be used for OS development, but it's not recommended.
Re: Visual Studio for development?
I'm just curious, but why is it not recommended? I develop my OS with it, and I haven't had any problems (other than the obvious "oh noes, MS toolchain can't do the ELF format" thing, but that doesn't count as a problem for me).Combuster wrote:There is a difference between the application used to compile your OS (generally cygwin), and the application used to write the code in (which can be anything, including Visual Studio)
Microsoft's compiler can be used for OS development, but it's not recommended.
Re: Visual Studio for development?
For one thing it's not portable. If you ever have a team of OS developers where some of them work on Linux, they'll have to rewrite the code because the code you write will only be VC++-compatible. So they'll have to use GCC or another compiler either way. If you never work in a team however, that's not a problem.ru2aqare wrote:I'm just curious, but why is it not recommended? I develop my OS with it, and I haven't had any problems (other than the obvious "oh noes, MS toolchain can't do the ELF format" thing, but that doesn't count as a problem for me).Combuster wrote:There is a difference between the application used to compile your OS (generally cygwin), and the application used to write the code in (which can be anything, including Visual Studio)
Microsoft's compiler can be used for OS development, but it's not recommended.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Re: Visual Studio for development?
Well I guess I have to install GCC and check this portability thing out, though I try not to use VC-specific features... However the same can be said of code written for GCC, some sources contain a lot of GCC-isms (for example, __attribute__), and I don't think that is portable.Creature wrote:For one thing it's not portable. If you ever have a team of OS developers where some of them work on Linux, they'll have to rewrite the code because the code you write will only be VC++-compatible. So they'll have to use GCC or another compiler either way. If you never work in a team however, that's not a problem.
Re: Visual Studio for development?
Yes, that's true , but they assume everybody uses GCC!ru2aqare wrote:Well I guess I have to install GCC and check this portability thing out, though I try not to use VC-specific features... However the same can be said of code written for GCC, some sources contain a lot of GCC-isms (for example, __attribute__), and I don't think that is portable.Creature wrote:For one thing it's not portable. If you ever have a team of OS developers where some of them work on Linux, they'll have to rewrite the code because the code you write will only be VC++-compatible. So they'll have to use GCC or another compiler either way. If you never work in a team however, that's not a problem.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Re: Visual Studio for development?
Meh, in my kernel, I have things like #define __malloc __attribute__((malloc))Creature wrote:Yes, that's true , but they assume everybody uses GCC!ru2aqare wrote:Well I guess I have to install GCC and check this portability thing out, though I try not to use VC-specific features... However the same can be said of code written for GCC, some sources contain a lot of GCC-isms (for example, __attribute__), and I don't think that is portable.Creature wrote:For one thing it's not portable. If you ever have a team of OS developers where some of them work on Linux, they'll have to rewrite the code because the code you write will only be VC++-compatible. So they'll have to use GCC or another compiler either way. If you never work in a team however, that's not a problem.
Then I have further checks for GCC, PCC, etc, and their versions, which #define away __attribute__ entirely if it's not supported. All the code is written using __malloc, __noreturn, and things like that, and #defined as appropriate by the pre-processor come compile time. I find that correctly handles the case of specifics not being supported by one compiler (usually PCC) while it is supported by another (like GCC). The resulting binary isn't much different, and it really shouldn't result in different behavior either wrt bugs in the code but it may result in more or less warnings during compile, shorter or longer compile times, and faster or slower running code.
I also find this keeps the code internally clean and consistent, with the only parts that may not be all that easy to follow are the header files that handle all the pre-processor magic to eliminate the unsupported code.
Re: Visual Studio for development?
This is why in any medium sized project (100+ kloc) or larger that require portability as a requirement needs to be designed to provide an abstraction of compilier dependencies. Most larger projects that I have seen and worked with provide a basic set of preprocessor constants and names used just for this purpose and allows you to hide compilier dependencies behind a common interface and make build envirements more portable.
In other words, any project properly designed written using MSVC++ dependencies can be compilied to run under GCC through a common interface. (In the case of OS development, however, keep in mind the basic CRT startup code will also be different.)
In other words, any project properly designed written using MSVC++ dependencies can be compilied to run under GCC through a common interface. (In the case of OS development, however, keep in mind the basic CRT startup code will also be different.)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Visual Studio for development?
CRT? Aren't most (if not all) kernels compiled standalone (meaning CRT isn't used)? I know all the tutorials I've read do it that way.neon wrote:(In the case of OS development, however, keep in mind the basic CRT startup code will also be different.)
Re: Visual Studio for development?
Not quite. CRT does not necessarily mean the CRT used by default for the compilier. It can also be your stand alone CRT which may be used fine for kernels and other system software components. (Example of usage: my (real) system and WinNT/2000 kernels).JohnnyTheDon wrote:CRT? Aren't most (if not all) kernels compiled standalone (meaning CRT isn't used)? I know all the tutorials I've read do it that way.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Visual Studio for development?
Oh, you mean the CRT you create yourself will be different depending on the compiler. Understood.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Visual Studio for development?
You can recompile GCC (and many other open source compilers) for your own OS. You cannot however recompile visual studio.For one thing it's not portable. If you ever have a team of OS developers where some of them work on Linux, they'll have to rewrite the code because the code you write will only be VC++-compatible. So they'll have to use GCC or another compiler either way. If you never work in a team however, that's not a problem.Creature wrote:I'm just curious, but why is it not recommended? I develop my OS with it, and I haven't had any problems (other than the obvious "oh noes, MS toolchain can't do the ELF format" thing, but that doesn't count as a problem for me).
Then there's that awkward MASM license (making osdev with it illegal).
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Visual Studio for development?
Seriously? How did they manage that one?Then there's that awkward MASM license (making osdev with it illegal).