g++

With g++ is there a runtime setting to scramble freed memory with delete?

Does anyone know how I can for the g++ or gcc runtime to scramble the ram where an object was after delete? I have a theory that I'm using an object after it has been deleted but in practice it rarely crashes. ...

g++ __static_initialization_and_destruction_0(int, int) - what is it

Hello After compiling of c++ file (with global static object) I get in nm output this function: 00000000 t _Z41__static_initialization_and_destruction_0ii __static_initialization_and_destruction_0(int, int) /* after c++filt */ What is it? It will call __cxa_atexit() Can I disable generation of this function (and calling a __cxa_...

new with exception with Microsoft

As I'm coding for both Windows and Linux, I have a whole host of problems. Microsoft Visual C++ has no stdint header, but for that I wrote my own. Now I found out that MS C++'s new operator does not throw an exception, so I want to fix this a quickly as possible. I know I can define a Macro with Parameters in Parenthesis, can I define a...

cc1plus: error: include: Value too large for defined data type when compiling with g++

I am making a project that should compile on Windows and Linux. I have made the project in Visual Studio and then made a makefile for linux. I created all the files in Windows with VS. It compiles and runs perfectly in VS but when I run the makefile and it runs g++ I get $ g++ -c -I include -o obj/Linux_x86/Server.obj src/Server.cpp cc...

Eclipse CDT: hieroglyphs in console and problem list

Recently, I switched from Visual Studio to Eclipse CDT. I've set it up beautifully such that the G++ compiler from my Cygwin installation can locate and compile my code without ado. There is a minor grievance, however. Each time G++ reports a warning or error, the curly single quotes ‘ and ’ appear as ‘ respectively ’. It seems like...

Mixins, variadic templates, and CRTP in C++

Here's the scenario: I'd like to have a host class that can have a variable number of mixins (not too hard with variadic templates--see for example http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.103.144). However, I'd also like the mixins to be parameterized by the host class, so that they can refer to its public types (using th...

g++ C++0x enum class Compiler Warnings

I've been refactoring my horrible mess of C++ type-safe psuedo-enums to the new C++0x type-safe enums because they're way more readable. Anyway, I use them in exported classes, so I explicitly mark them to be exported: enum class __attribute__((visibility("default"))) MyEnum : unsigned int { One = 1, Two = 2 }; Compiling thi...

Is it possible to create a null function that will not produce warnings?

I have a logger in a c++ application that uses defines as follows: #define FINEST(...) Logger::Log(FINEST, _FILE, __LINE, __func, __VA_ARGS_) However what I would like to do is to be able to switch off these logs since they have a serious performance impact on my system. And, it's not sufficient to simply have my Logger not write to ...

Linking to MSVC DLL from MinGW

I'm trying to link the LizardTech GeoExpress DSDK into my own application. I use gcc so that we can compile on for platforms. On Linux and Mac this works easily: they provide a static library (libltidsdk.a) and headers and all that we have to do is use them. Compiling for windows isn't so easy. They've built the library using Microso...

Atomic swap in GNU C++

I want to verify that my understanding is correct. This kind of thing is tricky so I'm almost sure I am missing something. I have a program consisting of a real-time thread and a non-real-time thread. I want the non-RT thread to be able to swap a pointer to memory that is used by the RT thread. From the docs, my understanding is that...

Compilation failing - no #include - boost

Hi, I'm trying to compile a third-party library, but g++ is complaining about the following line: typedef boost::shared_ptr<MessageConsumer> MessageConsumerPtr; The strange thing is, there is no #include directive in the file - and it is clearly supposed to be this way; there are about 60 files with the same (or very similar) issues....

How do I get rid of LD_LIBRARY_PATH at run-time?

I am building a C++ application that uses Intel's IPP library. This library is installed by default in /opt and requires you to set LD_LIBRARY_PATH both for compiling and for running your software (if you choose the shared library linking, which I did). I already modified my configure.ac/Makefile.am so that I do not need to set that vari...

MinGW Doesn't Generate an Object File When Compiling

I've just bought a new laptop for me on the travel, then on my free time, I've started to test MinGW on it by trying to compile my own OS that is written in C++, then I've created all the files needed and the kernel.cpp: extern "C" void _main(struct multiboot_data* mbd, unsigned int magic); void _main( struct multiboot_data* mbd, unsig...

What does "error: invalid function declaration" mean?

With GCC 4.1.2, I get the error tmp.cpp:8: error: invalid function declaration for the following code namespace edit { class A { public: void foo( ); }; } void edit:A::foo( ) { } ...

How to use std::allocator in my own container class

I am trying to write a container class which uses STL allocators. What I currently do is to have a private member std::allocator<T> alloc_; (this will later be templated so that the user can pick a different allocator) and then call T* ptr = alloc_.allocate(1,0); to get a pointer to a newly allocated 'T' object (and used alloc_.con...

How to fix this Makefile

I want my Makefile to be as simple as possible and still function. This is what it looks like. load: load.cpp g++ load.cpp -g -o load list: list.cpp g++ list.cpp -g -o list It worked fine when there was only one entry. But when I added the second entry, it doesn't check to see if it's updated and needs to be recompiled, unle...

How to directly access a certain part of a text file in g++?

I have a text file containing a number of records. Each record is stored on a single line that is 100 characters long. Let's say I want to directly access the nth record. I could do it using a for loop, reading in n lines until I get to the record. But how could I access it directly? ...

HP-UX: libstd_v2 in stack trace of JNI code compiled with g++

Hello, uname -mr: B.11.23 ia64 g++ --version: g++ (GCC) 4.4.0 java -version: Java(TM) SE Runtime Environment (build 1.6.0.06-jinteg_20_jan_2010_05_50-b00) Java HotSpot(TM) Server VM (build 14.3-b01-jre1.6.0.06-rc1, mixed mode) I'm trying to run a Java application that uses JNI. It is crashing inside the JNI code with the following (...

What does this mean: warning: converting from ‘void (ClassName::*)()’ to ‘void (*)()’

I have a member function in a class that has a callback, but the callback isn't strictly neccessary, so it has a default callback, which is empty. It seems to work fine, but I get an annoying warning: warning: converting from ‘void (ClassName::*)()’ to ‘void (*)()’ I'm trying to figure out what it means and how to turn it off (or fix ...

How to append to the beginning of a text fle in g++

I want to write to a file without overwriting anything. It is a text file containing records. When I delete a specific record, I do not actually remove it from the file, I just put information in the header saying that it is deleted. How can I do this? ...