Is it possible to obtain a list of preprocessor #define'd symbols in VC++? I know GCC has similar options to dump all effective #define symbols for the supplied .cpp/.h source files, but I am not sure if VC++ support this?
I am using a Mozilla open source project in Windows. There are a lots of irrelevant #define for the UNIX build env causing the source code very unreadable. I want to eliminate the irrelevant #define from the source code. The project uses Mozilla specific build scripts (automake, configure, Makefile, python scripts, and etc) to supply the symbol definitions to the compiler dynamically. Also each source file add its own #define at different #ifdef branches making manually pre-determining the complete list of symbols for a specific build impractical.
Check out Macros and Constants list in the View => Class View menu.
Related
Is there a way to find out what preprocessors are defined in your linux driver/kernel code when building? I could use a text search tool (I actually did), but I inherit a big tree of linux driver/kernel code. It's so big that my text search tool gets an error when I search for a certain preprocessor in the whole code tree.
gcc can dump all defined macros to stdout in preprocessing mode:
gcc -E -dM foo.c
This includes any macros predefined by the compiler, which can be a little annoying. In any case, you should be able to hack up your Makefile to contain a target that dumps this information to files for each compilation unit.
To get from C++ sourcecode to a binary module, the process is roughly as follows:
set_of_source_files[a.cpp, b.cpp, ...] // conceptually, it doesn't matter where these are
||
|| Compiler <- [compiler_settings]
\/
set_of_object_files
||
|| Linker <- [linker_settings]
\/
binary module (dynamic library or executable)
Now, I know Visual Studio projects, they
Define a set of source files (directory structure and layout basically doesn't matter / is defined inside the project file)
Define the compiler settings for all (optionally each) of the source files
Define the linker settings
Define where to put generated output files
I don't know cmake, but apparently(?), the info one configures with cmake differs slightly from the info one puts into vc[x]proj files.
Is a "cmake configuration" just a differently formatted "vcproj file" or is there a conceptual difference? (Except for the obvious one (I assume) that the info I put into a cmake configuration is platform independent.)
An alternative twist to this question would be to answer -- in the context of above -- why/if(?) one would switch to cmake when only compiling for Windows with Visual-C++.
Cmake is a cross-platform make -- it starts from a set of source files and a relatively abstract set of directions about what to do with them. Based on those, it generates a set of platform-specific files. If you specify Windows/Visual Studio as the target, it can/will generate a vx[x]proj file for you to use.
Even if you're only using Visual C++ on Windows, it's possible you could benefit from cmake. The obvious possibility would be if you want to target a number of different versions of Visual Studio, and be able to directly generate the correct files for each, instead of generating files for the oldest version you want to support, and then depend on Visual Studio's upgrade feature to convert those to the target version.
Based on my experience with VS's upgrade capability (not particularly great), I'd say that could/would be a reasonable and valid use.
I need to use Visual C++ to build a customized Apache web server. Here is the goal I am trying to achieve: specify some of the functions or data in Apache source code, and put them in separate and 4k-page aligned sections (not .text .data .bss) of output .exe file.
The closet solution I can find online is use /Gy compiler options to compile each functions into different COMDATs, and then use /ORDER linker options to put the COMDATs in a predetermined order. However, it is just reordering inside a section, not changing the section layout in .exe output or creating a new section. Under Linux, I can use compiler attribute "section" and linker script to fulfill my goal. Are there equivalent solution in Visual C++? Thanks very much:-)
#pragma code_seg lets you specify the segment into which code will be placed. Along with being able to specify a name, the compiler keeps a stack of names so you can push and pop the current state if you want.
I want that whenever i open a new c++ file in vim in linux ( mandriva 2010 ) the following code gets inserted in it automatically :
Default code :
#include <iostream>
using namespace std;
int main()
{
return 0;
}
Is there any way to get it done. also can i bind .py, .pl, .java files with similar things. Moreover i should be able to change the default code for a file.
For customizable headers, code completion, as well as a host of other features specific to C++, try c.vim
One common method for doing this is described at :help template.
Another option would be to use a snippets plugin (like snipMate or UltiSnips). These don't automatically insert the code when you open a new file, but you can create various snippets that will expand to portions of the template you describe and let you fill in the portions that vary (like the header in an #include <...> statement).
Regarding C&C++, muTemplate goes a step further. When creating a new source file (.cpp, .c, ...), if a header file with the same base name is detected in the vicinity, it is automatically included -- in the case the alternate plugin (a.vim) is installed, its detection heuristic is automatically exploited (in some projects, source files and header files are not in the same directory).
NB: files headers (i.e. copyright/VCS stuff can be overridden)
I want to make a "standard" install for external use, but I also want to use the same script and tell it (with a command line param perhaps?) to include another set of files (PDB files for debugging) for our lab installations. (And make a totally different install exe)
How can I do this? Is it possible?
I don't see how to set this in the [Files] section (conditionally add files based on some value/param)
Note – this is not for allowing the user an option DURING the install. I want a build-time option to set in my hudson build or batch file.
I suppose I can just create a separate installer for the pdbs, but I'd rather just have one file to do everything.
You can simply use
#ifdef DebugVersion
File: *.pdb ...
#endif
and then call the Inno compiler like this:
iscc.exe -DDebugVersion ...
I'd also add something like this so you get different output file names:
#ifdef DebugVersion
OutputBaseFileName=mysetup-dbg
#else
OutputBaseFileName=mysetup
#endif
Note that you'll probably need the InnoSetup precompiler for this, which, for some inexplicable reason, is not part of the default InnoSetup package. The easiest way to get it is to get the "Quick Start Pack" from the InnoSetup download page.
The answer is simple: create two files for each release, but put the common stuff in a third file and #include it in the other two.
http://rickborup.blogspot.com/2006/09/inno-setup-include-directive.html