Visual Studio: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
No edit summary |
removed pre in "Compiler Options" section |
||
Line 79: | Line 79: | ||
==== General ==== |
==== General ==== |
||
* Output Directory: . |
|||
<pre> |
|||
: Add a post-build step to copy only the ''real'' output file to the bin directory. Otherwise VS puts .lib and some linker files there as well. |
|||
: - Output Directory: . |
|||
* Intermediate Directory: . |
|||
: Add a post-build step to copy only the ''real'' output file to the bin directory. |
|||
: Otherwise VS puts .lib and some linker files there as well. |
|||
: - Intermediate Directory: . |
|||
</pre> |
|||
==== C/C++ :: General ==== |
==== C/C++ :: General ==== |
||
* Additional Include Directories: <set as needed> |
|||
<pre> |
|||
* Debug Information Format: Disabled |
|||
: - Additional Include Directories: <set as needed> |
|||
: At the stage my OS is in, I have no use for PDB files. I am in the process of writing a debugger, though, so in the future this could change. |
|||
: - Debug Information Format: Disabled |
|||
* Warning Level: Level 4 (/W4) |
|||
: At the stage my OS is in, I have no use for PDB files. I am in the process |
|||
* Detect 64-bit Portability Issues: No |
|||
: of writing a debugger, though, so in the future this could change. |
|||
: This relies on a special __w64 token in various typedefs. I do not know how to use this with my OS. Just be careful: int and long are still 32-bit if compiling for a x64 target (using VS 2005) |
|||
: - Warning Level: Level 4 (/W4) |
|||
: - Detect 64-bit Portability Issues: No |
|||
: This relies on a special __w64 token in various typedefs. I do not know how |
|||
: to use this with my OS. Just be careful: int and long are still 32-bit |
|||
: if compiling for a x64 target (using VS 2005) |
|||
</pre> |
|||
==== C/C++ :: Optimization ==== |
==== C/C++ :: Optimization ==== |
||
* Optimization: Minimize Size (/O1) |
|||
<pre> |
|||
: This is really up to you. For me, space is more important than speed for now, but this can easily be changed. If you are implementing source-level debugging, you might want to disable all optimizations. |
|||
: - Optimization: Minimize Size (/O1) |
|||
* Global Optimizations: Yes (/Og) |
|||
: This is really up to you. For me, space is more important than speed for now, |
|||
: but this can easily be changed. If you are implementing source-level debugging, |
|||
: you might want to disable all optimizations. |
|||
: - Global Optimizations: Yes (/Og) |
|||
: Again, enable only if not using a source-level debugger |
: Again, enable only if not using a source-level debugger |
||
* Favor Size Or Speed: Favor Small Code (/Os) |
|||
: Set as needed, only if /Og enabled |
: Set as needed, only if /Og enabled |
||
* Optimize for Processor: Pentium Pro, II, III (/G6) |
|||
: Set as needed |
: Set as needed |
||
</pre> |
|||
==== C/C++ :: Preprocessor ==== |
==== C/C++ :: Preprocessor ==== |
||
* Ignore Standard Include Path: Yes (/X) |
|||
<pre> |
|||
: - Ignore Standard Include Path: Yes (/X) |
|||
</pre> |
|||
==== C/C++ :: Code Generation ==== |
==== C/C++ :: Code Generation ==== |
||
* Enable String Pooling: Yes (/GF) |
|||
<pre> |
|||
: Places string literals in a read-only data section. This doesn't mean much for OS code, but enable this ONLY if you do not modify string literals in-place, as this would change it in all instances. |
|||
: - Enable String Pooling: Yes (/GF) |
|||
* Enable Minimal Rebuild: No |
|||
: Places string literals in a read-only data section. This doesn't mean much for OS |
|||
: Rebuilds seem to go fast enough, and enabling this seems to add 0xCC pad bytes to the EXE, which causes bloating. |
|||
: code, but enable this ONLY if you do not modify string literals in-place, as this |
|||
* Enable C++ Exceptions: No |
|||
: would change it in all instances. |
|||
: Unless you have an exceptional (pun intended) configuration, these require runtime support and are generally not needed anyways. |
|||
: - Enable Minimal Rebuild: No |
|||
* Basic Runtime Checks: Default |
|||
: Rebuilds seem to go fast enough, and enabling this seems to add 0xCC pad bytes to |
|||
: the EXE, which causes bloating. |
|||
: - Enable C++ Exceptions: No |
|||
: Unless you have an exceptional (pun intended) configuration, these require runtime |
|||
: support and are generally not needed anyways. |
|||
: - Basic Runtime Checks: Default |
|||
: Enabling any runtime checks requires special support code. |
: Enabling any runtime checks requires special support code. |
||
* Struct Member Alignment: 1 Byte (/Zp1) |
|||
: This is really up to you, but most structs that I have need to be aligned this way. |
: This is really up to you, but most structs that I have need to be aligned this way. If you choose default (8 byte), you can use #pragma pack(push, 1) and #pragma pack(pop) to adjust the packing. Consult MSDN for more info. |
||
* Buffer Security Check: No |
|||
: If you choose default (8 byte), you can use #pragma pack(push, 1) and #pragma pack(pop) |
|||
: to adjust the packing. Consult MSDN for more info. |
|||
: - Buffer Security Check: No |
|||
: Again, this requires runtime support code |
: Again, this requires runtime support code |
||
</pre> |
|||
==== C/C++ (misc. options) ==== |
==== C/C++ (misc. options) ==== |
||
* Language |
|||
<pre> |
|||
* Force Conformance in For Loop Scope: Yes (/Zc:forScope) |
|||
: - Language |
|||
: - Force Conformance in For Loop Scope: Yes (/Zc:forScope) |
|||
: A Good Idea. Makes the ''i'' in ''for (int i = 0; ...)'' local to the loop. |
: A Good Idea. Makes the ''i'' in ''for (int i = 0; ...)'' local to the loop. |
||
* Output Files |
|||
* Assembler Output: Assembly, Machine Code, and Source (/FAcs) |
|||
: Outputs the assembly listing of the code to files in a given directory. This is |
: Outputs the assembly listing of the code to files in a given directory. This is nice for assembly-level debugging, as it has the source code lines nearby. |
||
* ASM List Location: <directory>\ |
|||
: nice for assembly-level debugging, as it has the source code lines nearby. |
|||
: - ASM List Location: <directory>\ |
|||
: Make sure there is a terminating \, otherwise VS will try to put everything in one file. |
: Make sure there is a terminating \, otherwise VS will try to put everything in one file. |
||
* Advanced |
|||
* Calling Convention: __stdcall (/Gz) |
|||
: Again, up to you, but I find the lack of name decoration handy for debugging. Functions |
: Again, up to you, but I find the lack of name decoration handy for debugging. Functions declared ''extern "C" void [[Do Something]](int p1, int p2)'' show up as _[[Do Something]]@8 rather than ?@[[Do Something]]@YAXZSASD or similar. |
||
* Command Line |
|||
: declared ''extern "C" void [[Do Something]](int p1, int p2)'' show up as _[[Do Something]]@8 rather |
|||
* /Oy- |
|||
: than ?@[[Do Something]]@YAXZSASD or similar. |
|||
: Disables frame pointer (EBP) omission, included with optimization for size. This is handy to get stack backtraces in case of a crash. |
|||
: - Command Line |
|||
: - /Oy- |
|||
: Disables frame pointer (EBP) omission, included with optimization for size. This is handy |
|||
: to get stack backtraces in case of a crash. |
|||
</pre> |
|||
==== Linker ==== |
==== Linker ==== |
||
* General |
|||
<pre> |
|||
* Output File: <set as needed> |
|||
: - General |
|||
* Enable Incremental Linking: No (/INCREMENTAL:NO) |
|||
: - Output File: <set as needed> |
|||
: - Enable Incremental Linking: No (/INCREMENTAL:NO) |
|||
: Reduces the bloat of the generated EXE or DLL. Linking seems fast enough, anyways. |
: Reduces the bloat of the generated EXE or DLL. Linking seems fast enough, anyways. |
||
* Additional Library Directories: <set as needed> |
|||
* Input |
|||
* Ignore All Default Libraries: Yes (/NODEFAULTLIB) |
|||
: Ignores the default libc.lib, libcmt.lib, etc. |
: Ignores the default libc.lib, libcmt.lib, etc. |
||
* Debugging |
|||
* Generate Debug Info: No |
|||
: Until I create a better debugger for my OS, I have no use for this. Set as needed. |
: Until I create a better debugger for my OS, I have no use for this. Set as needed. |
||
* Generate Map File: Yes (/MAP) |
|||
: Generates a map file (function name and address) and actually ''sorts'' by ascending |
: Generates a map file (function name and address) and actually ''sorts'' by ascending address, unlike GCC. |
||
* Map File Name: <set as needed> |
|||
: address, unlike GCC. |
|||
* Optimization |
|||
: - Map File Name: <set as needed> |
|||
* References: Eliminate Unreferenced Data |
|||
: - Optimization |
|||
* Enable COMDAT Folding: Remove Redundant COMDATs |
|||
: - References: Eliminate Unreferenced Data |
|||
* Advanced |
|||
: - Enable COMDAT Folding: Remove Redundant COMDATs |
|||
* Entry Point: <set as needed> |
|||
: - Advanced |
|||
: The linker will complain if it is not __stdcall with 12 bytes of arguments (3 32-bit params), but is only a warning. |
|||
: - Entry Point: <set as needed> |
|||
* Fixed Base Address: Generate a relocation section |
|||
: The linker will complain if it is not __stdcall with 12 bytes of arguments |
|||
: (3 32-bit params), but is only a warning. |
|||
: - Fixed Base Address: Generate a relocation section |
|||
: Images will be relocated later. See below. |
: Images will be relocated later. See below. |
||
* Command Line |
|||
* /DRIVER |
|||
* /ALIGN: 512 |
|||
: Together, they set the [[Section Alignment]] and [[File Alignment]] to 512 bytes. My boot loader |
: Together, they set the [[Section Alignment]] and [[File Alignment]] to 512 bytes. My boot loader is not sophisticated enough to handle these being different. The downside is that restrictions (read-only, etc) on sections are meaningless, as they require page-granularity for hopefully obvious reasons. |
||
: is not sophisticated enough to handle these being different. The downside is that |
|||
: restrictions (read-only, etc) on sections are meaningless, as they require page- |
|||
: granularity for hopefully obvious reasons. |
|||
</pre> |
|||