g++

Using GSL with cygwin g++

Hello, trying to get the Gnu Scientific Library (gsl) to work in cygwin g++. Cygwin is installed and updated with all default parameters and includes gsl:runtime, gsl-apps and gsl-doc. I am trying the example program given in the gsl website: http://www.gnu.org/software/gsl/manual/html%5Fnode/An-Example-Program.html include #inclu...

How to build in release mode with optimizations in GCC?

Hello, What are the specific options I would need to build in "release mode" with full optimizations in GCC? If there are more than one option, please list them all. Thanks. ...

Swap 2D Double Arrays in c++

I have the following method to swap two double arrays (double**) in c++. Profiling the code, the method is accounting for 7% of the runtime... I was thinking that this should be a low cost operation, any suggestions? I am new with c++, but i was hoping to just swap the references to the arrays. 62 void Solver::Swap(double** &v1, dou...

C++: How can a public static member function access private instance member variables?

I'm writing a C++ class to read input from a file into preallocated buffers called "chunks". I want the caller to be able to call a public static Chunk class method called GetNextFilledChunk(), which Grabs a Chunk from an inactive chunk pool Fills the Chunk instance from the input stream using the Chunk's private member variables/func...

g++ power function included in g++ compiler

can power function be used to calulate the power of very large values like pow(200,200). also can it be used for long long int values ... pow(long long int,long long int). i am getting this error /sources/tested.cpp: In function 'int main()': /sources/tested.cpp:16: error: call of overloaded 'pow(long long int&, long long int&)' is amb...

How to know when to use the .a or .so when linking to Boost?

I wanted to try out the Boost::Serialization library for a project I'm working on. I'm also trying to get used to programming in Linux as well. I set up boost in its default locations. I tried compiling the test file they provide here with the command line arguments they provide and it worked fine. In this example they use the .a file. ...

gcc warning" 'will be initialized after'

I am getting a lot of these warnings from 3rd party code that I cannot modify. Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)? Example: list.h:1122: warning: `list<LogOutput*, allocator<LogOutput*> >::node_alloc_' will be initialized after list.h:1117: warning: `alloca...

Error: expected constructor, destructor, or type conversion before ';' token?

I'm trying to compile my code to test a function to read and print a data file, but I get a compiling error that I don't understand - "error: expected constructor, destructor, or type conversion before ';' token". Wall of relevant code-text is below. struct Day { int DayNum; int TempMax; int TempMin; double Precip; int TempRa...

g++ doesn't like template method chaining on template var?

I'm trying to compile with g++ some code previously developed under Visual C++ 2008 Express Edition, and it looks like g++ won't let me call a template method on a reference returned by a method of a template variable. I was able to narrow the problem down to the following code: class Inner { public: template<typename T> T get() con...

Why can you return from a non-void function without returning a value without producing a compiler error?

Ever since I realized many years ago, that this doesn't produce an error by default, (in gcc at least) I've always wondered why? I understand that you can issue compiler flags to produce a warning, but shouldn't it always be an error? Why does it make sense for a non-void function not returning value to be valid? An example as requeste...

Remote programming and debugging

Hi there, I have to program a C/C++ application. I have windows and linux (ubuntu 9.04) in my machine, and can program in both of them (via gcc/code blocks/vim,etc). The problem is that the executable is going to be run in a Unix (not linux) machine (will have access to it in about 20 days). My Team Leader doesn´t want all of the code...

Compiling a binary to work with valgrind on Snow Leopard

I installed valgrind on Snow Leopard using the patch at https://bugs.kde.org/show%5Fbug.cgi?id=205241 . However, when I run it with a binary I compiled from C++ code, I'm told that valgrind "cannot execute binary file". What g++ flags should I set to make my program work with valgrind? ...

NOT sharing all classes with shared library

As ugly as win32 Microsoft compiler is by using the __declspec macro, it does have the advantage of being explicit about what you want to export or not. Moving the same code onto a Linux gnu/gcc system now means all classes are exported!(?) Is this really true? Is there a way to NOT export a class within a shared library under gcc? #...

What caused the mysterious duplicate entry in my stack?

I'm investigating a deadlock bug. I took a core with gcore, and found that one of my functions seems to have called itself - even though it does not make a recursive function call. Here's a fragment of the stack from gdb: Thread 18 (Thread 4035926944 (LWP 23449)): #0 0xffffe410 in __kernel_vsyscall () #1 0x005133de in __lll_mutex_loc...

Strange performance problem.

I have a container similar to this one. template <typename Nat, typename Elt> class NatMap { public: Elt& operator[] (Nat nat) { return tab [nat.GetRaw()]; } private: Elt tab [Nat::kBound]; }; I wanted to drop the requirement for Elt to have a default constructor: template <typename Nat, typename Elt> class NatMap { pub...

Can you give an example of stack overflow in C++?

Can you give an example of stack overflow in C++? Other than the recursive case: void foo() { foo(); } ...

C++ Newbie in Linker Hell

Hello all, Using g++ and having linker errors. I have a simple program in split into two modules: main.cpp and Dice.h Dice.cpp. main.cpp: #include <iostream> #include "Dice.h" int main(int argc, char **argv) { int dieRoll = Dice::roll(6); std::cout<<dieRoll<<std::endl; std::cin.get(); return 0; } Dice.h: #ifnde...

What are the best RSS feeds for C++ ?

What are the best RSS feeds for C++ ? ...

No rule to make target ... libm.a

I get the following error when I try to compile my app: *** No rule to make target `/mypath/lib/libm.a', needed by `/myPath/bin/appName' Why is the linker looking for libm.a according to an absolute path? ...

"g++" and "c++" compiler

Hi, I just found on my Ubuntu, there are two different C++ compiler: /usr/bin/g++ and /usr/bin/c++. I am not familiar with the latter, but man c++ just jumps to the manpage of gcc. I wonder what is their difference as C++ compilers? Thanks and regards! ...