How to view C preprocessor output?

gcc -E file.c or g++ -E file.cpp will do this for you. The -E switch forces the compiler to stop after the preprocessing phase, spitting all it’s got at the moment to standard output. Note: Surely you must have some #include directives. The included files get preprocessed, too, so you might get lots of output. … Read more

pure/const function attributes in different compilers

GCC: pure/const function attributes llvm-gcc: supports the GCC pure/const attributes Clang: seems to support it (I tried on a simple example with the GCC style attributes and it worked.) ICC: seems to adopt the GCC attributes (Sorry, only a forum post.) MSVC: Seems not to support it. (discussion) In general, it seems that almost all … Read more

What is the VTT for a class?

The page “Notes on Multiple Inheritance in GCC C++ Compiler v4.0.1” is offline now, and http://web.archive.org didn’t archive it. So, I have found a copy of the text at tinydrblog which is archived at the web archive. There is full text of the original Notes, published online as part of “Doctoral Programming Language Seminar: GCC … Read more

Is free() zeroing out memory?

There’s no single definitive answer to your question. Firstly, the external behavior of a freed block will depend on whether it was released to the system or stored as a free block in the internal memory pool of the process or C runtime library. In modern OSes the memory “returned to the system” will become … Read more

What is the branch in the destructor reported by gcov?

In a typical implementation the destructor usually has two branches: one for non-dynamic object destruction, another for dynamic object destruction. The selection of a specific branch is performed through a hidden boolean parameter passed to the destructor by the caller. It is usually passed through a register as either 0 or 1. I would guess … Read more

tech