I had the following C++ code, where the argument to my constructor in the declaration had different constness than the definition of the constructor.
//testClass.hpp
class testClass {
public:
testClass(const int *x);
};
//testClass.cpp
testClass::testClass(const int * const x) {}
I was able to compile this with no warnings usi...
When I compile a c++ application I'm writing that makes use of hash_map, I get this warning on g++ 4.3.2:
You are using the deprecated header . To eliminate this warning, use an ANSI-standard header file or use hte -Wno-deprecated compiler flag.
9> #include <ext/hash_map>
What include replaces this? I've searched for a while on goog...
How can a cross compilation setup be achieved to allow compiling Cell Linux programs on a Windows PC using the cygwin toolchain? The cygwin tools provide a GNU compiler to use in building the cross compiler, and associated tools for the build process e.g. rpm, cpio, make, flex, bison and so on.
I am moderately confident this is possible...
Let's say that I have a binary that I am building, and I include a bunch of files that are never actually used, and do the subsequent linking to the libraries described by those include files? (again, these libraries are never used)
What are the negative consequences of this, beyond increased compile time?
...
I get the following errors when trying to compile the below code using g++. When I compile it using gcc it works fine (other than a few warnings). Any help appreciated.
g++ ush7.cpp
ush7.cpp: In function ‘int signalsetup(sigaction*, sigset_t*, void (*)(int))’:
ush7.cpp:93: error: expected unqualified-id before ‘catch’
ush7.cpp:95: err...
I use the following code to compile a cpp file to object file.
g++ -c main.cpp
Above code generates the .o fles in same directory where main.cpp resides.
Suppose I have a folder named obj and need to generate the object files there, how do I write?
How can I see the compiler switches supported by g++ and it's usages?
Any help wou...
There is a Debian g++-4.4 package,
but it's not Ubuntu. There are too many system-destroyed scary stories on the web.
How can I install g++ 4.4 on Ubuntu?
...
class foo
{
public:
void say_type_name()
{
std::cout << typeid(this).name() << std::endl;
}
};
int main()
{
foo f;;
f.say_type_name();
}
Above code prints P3foo on my ubuntu machine with g++. I am not getting why it is printing P3foo instead of just foo. If I change the code like
std::cout << typeid(*this).name() <...
I am new to makefiles. I learned makefile creation and other related concepts from "Managing projects with GNU make" book. The makefile is ready now and I need to make sure the one which I created is OK. Here is the makefile
#Main makefile which does the build
#makedepend flags
DFLAGS =
#Compiler flags
#if mode variable is empty, set...
I have an array of doubles and need to do a calculation on that array and then find the min and max value that results from that calculation. Here is basically what I have:
double * array;
double result;
double myMin;
double myMax;
// Assume array is initialized properly...
for (int i = 0; i < sizeOfArray; ++i) {
result = transmog...
I am just starting with g++ compiler on LINUX and got some questions on the compiler flags. Here are they
Optimizations
I read about optimization flags -O1,-O2 and -O3 in the g++ manual page. I didn't understood when to use these flags. Usually what optimization level do you use? g++ manual says the following for -O2.
Optimize even...
I've been playing about with functors in C++. In particular, I've got a vector of pairs I'd like to sort by the first element of the pair. I started off writing a completely specialised functor (i.e. something like "bool MyLessThan(MyPair &lhs, MyPair &rhs)"). Then, just because this sort of stuff is interesting, I wanted to try writing ...
So I am a new programmer and I just installed XCode on my Macbook to get the GCC. I think Xcode is the only way for getting GCC on OSX. Now when I run my Hello World application, in C++, g++ comes up saying it is version 4.0.1 but when I look for commands starting with g I also see g++-4.2. Is there any way of making 4.2 default rather t...
Using: windows xp, g++ 3.4.4 with cygwin and g++ 3.4.5 with mingw.
I'm compiling a simple unit test class with cppunit.
When I link using g++ 3.4.5 I get a lot of linking errors. When I link with g++ 3.4.4 I don't get any errors and the exe links fine and runs.
I can't seem to trace down the errors, so any thoughts?
Thanks.
ED...
Hi all,
Yesterday I ran into a g++ (3.4.6) compiler problem for code that I have been compiling without a problem using the Intel (9.0) compiler. Here's a code snippet that shows what happened:
template<typename A, typename B>
class Foo { };
struct Bar {
void method ( Foo<int,int> const& stuff = Foo<int,int>() );
};
The g++ compi...
Why do I get:
undefined reference to `CryptAcquireContext(unsigned int**, char const*, char const*, unsigned long, unsigned long)@20'
I am using the Mingw32 compiler suite.
...
I just installed Cygwin. And I can launch a bash shell from windows, do "ls", "emacs", "vi" , etc. However, when I do "g++" it says command not found.
I thought g++ was installed by default in Cygwin? If that's not the case, what is the exactly categories under which I can add g++ as a package to my cygwin?
Thanks!
...
I have boost C++ libraries already installed on my Fedora10 machine but I want to use a newer version that I keep at some location in my home folder. I want g++ to use include and library files from my home folder location instead of default (/usr/include and /usr/lib64).
For that matter, I also have declared CPLUS_INCLUDE_PATH and LIBR...
I feel dumb asking this, but here it goes. I use gcc/g++ on Linux and since my install is in spanish (my native language), gcc prints warnings and errors in spanish. I rather read them in english for two reasons:
English messages are far easier to google.
Spanish translations are more or less horrible.
Any help? I've googled for this...
When i try to
$ make depend -f gcc.mak
a middleware on my Ubuntu machine I get this
/usr/include/../include/limits.h:125:26: error: no include path in which to search for limits.h
This is the contents around limits.h:125:
/* Get the compiler's limits.h, which defines almost all the ISO constants.
We put this #include_next outs...