I have had success using Visual Studio .NET 2003 and Microsoft's compiler (and NASM for my bootloader, called from a pre-build step for the bootloader project). I don't want to start a flame war, so I will keep my opinion of GCC to myself.
Here are the project settings I use for my kernel:
C/C++
General
Debug Information Format : Disabled
Warning Level : Level 4
Preprocessor
Ignore Standard Include Path : Yes
Code Generation
Enable Minimal Rebuild : No (reduces size of stuff)
Enable C++ Exceptions : No
Basic Runtime Checks : Default
Runtime Library : (anything)
Buffer Security Check : No
Output Files
Assembler Output : Assembly, Machine Code, and Source
ASM list location : (some path, ex. ..\bin\asm\kernel\)
Advanced
Calling Convention : (any, I use __stdcall and extern "C" - no name decoration)
Command Line
Addtional Options : /Oy- (don't omit frame pointers - useful for debugging)
Linker
General
Enable Incremental Linking : No (reduces size)
Input
Ignore All Default Libraries : Yes
Debugging
Generate Debug Info : No
Generate Map File : Yes
Map File Name : (some path, ex. ..\bin\map\kernel.map)
Optimization
References : Eliminate Unreferenced Data
Enable COMDAT Folding : Remove Redundant COMDATs
Advanced
Entry Point : (your function, I use KeEntryPoint)
Fixed Base Address : Generate a relocation section
(use Rebase later - vc complains at base addr, or have bootloader rebase kernel)
Command Line
Additional Options : /DRIVER /ALIGN:512
With the /DRIVER, /ALIGN:512, your bootloader can simply read the PE file into memory and jump to the entry point address, provided the file is already rebased.
Any macros (va_list and friends) you can find in the CRT header files. To export functions from your kernel, you can use the __declspec(dllexport) and to import use __declspec(dllimport). You will have to write code to walk the import descriptor, though.
With this code,
Code: Select all
extern "C" int _outp(unsigned short, int);
extern "C" unsigned short _outpw(unsigned short, unsigned short);
extern "C" int _inp(unsigned short);
extern "C" unsigned short _inpw(unsigned short);
#pragma intrinsic(_inp, _inpw, _outp, _outpw)
you now have functions (they must have these names - you can always #define OutPortByte(prt, val) _outp(prt, val)) that are inline output functions.
Good luck,
Mike