gcc

Macros for GCC/G++ to differentiate Linux and Mac OSX?

Macros for GCC/G++ to differentiate Linux and Mac OSX? ...

Where to find __sync_add_and_fetch_8?

I got errors when trying to use __sync_add_and_fetch: test8.cpp:(.text+0x90e): undefined reference to `__sync_add_and_fetch_8' collect2: ld returned 1 exit status Please kindly advise how to rectify this. Specs: GCC/G++: 4.4.1 GNU/Linux 2.6.32 SMP i686 Many thanks! EDIT: In addition to the answer provided, one can use -march=i586 ...

What alternatives to __attribute__ exist on 64-bit kernels?

Hi: Is there any alternative to non-ISO gcc specific extension __attribute__ on 64-bit kernels ? Three types that i've noticed are: function attributes, type attributes and variable attributes. eg. i'd like to avoid using __attribute__((__packed__)) for structures passed over the network, even though some gcc based code do use it. An...

GCJ Creates duplicate dummy symbol

Hi, I'm trying to build a java application with gcj but getting the error below. It's been a while since I've used gcj (a year or so), so I may have forgot something non obvious but I'm pretty sure this is how I've always done it. multiple definition of `java resource .dummy' gcj versions are 4.4.1 on Ubuntu and 4.3.4 on cygwin/wind...

Referencing invalid memory locations with C++ Iterators

I am a big fan of GCC, but recently I noticed a vague anomaly. Using __gnu_cxx::__normal_iterator (ie, the most common iterator type used in libstdc++, the C++ STL) it is possible to refer to an arbitrary memory location and even change its value without causing an exception! Is this expected behavior? If so, isn't a security loophole? ...

Using GCC (MinGW) to compile OpenGL on Windows

I've searched on google and haven't been able to come up with a solution. I would like to compile some OpenGL programming using GCC. In the GL folder in GCC I have the following headers: gl.h glext.h glu.h Then in my system32 file I have the following .dll opengl32.dll glu32.dll glut32.dll If I wanted to write a simple OpenGL "He...

`enable_shared_from_this` has a non-virtual destructor

I have a pet project with which I experiment with new features of the upcoming C++0x standard. While I have experience with C, I'm fairly new to C++. To train myself into best practices, (besides reading a lot), I have enabled some strict compiler parameters (using GCC 4.4.1): -std=c++0x -Werror -Wall -Winline -Weffc++ -pedantic-errors ...

Conflicting PACKAGE_NAME and other macros when using autotools.

When using autotools (with a config.h file) for both a library, and a software built on that library, the compiler complains about a redefinition of some macros (PACKAGE_NAME, PACKAGE_TARNAME and so on). How can I prevent this? The config.h file is needed in the library to propagate it's setting to the software that use it. Right now ...

Problem with glaux.h locating

Hello, I try to compile code, that beggins with: #include<stdlib.h> #include<GL/gl.h> #include<glaux.h> with command: cc -o test test.c -I/usr/local/include -L/usr/local/lib -lMesaaux -lMesatk -lMesaGL -lXext -lX11 -lm But one of errors I got is: test.c:3:18: error: glaux.h: No such file or directory Then I try: yum provides ...

gcc : Is using -Werror and -pedantic considered good practice?

I'm just digging into the gcc manual and some things are still unclear to me: When specifying a std, should I always use -pedantic in conjunction? When using -g, it the standard level sufficient or should I specify level 3, i.e. -g3? Is it good practice to use -Werror to promote all warnings to errors and -pedantic-errors to promote al...

Link User32 with gcc

I have a C program which has a function call that is defined in windows.h (which I have included), however, when I try and compile it with gcc, I get the error: warning: implicit declaration of function `LockWorkStation' I looked at the MSDN documentation and I see that this function is the User32 library file, and I was wondering ho...

the problem about different treatment to __VA_ARGS__ when using VS 2008 and GCC

I am trying to identify a problem because of an unusual usage of variadic macros. Here is the hypothetic macro: #define va(c, d, ...) c(d, __VA_ARGS__) #define var(a, b, ...) va(__VA_ARGS__, a, b) var(2, 3, printf, “%d %d %d\n”, 1); For gcc, the preprocessor will output printf("%d %d %d\n", 1, 2, 3) but for VS 2008, the output is ...

Ruby in DOS CLI, How to do?

I see in a lot of the tutorials and how to pages, they use the following, or something similar ruby C:\test.rb Which would parse test.rb to the interpreter and ... execute the script. But how is this done a on a windows? Ruby isn't a recognized internal command (as per the DOS output)? I know how to do all these things on Linux, and i...

-I dir vs. -isystem dir

If I want to include directories to be searched for header files, which is the preferred way and why? ...

Does a c/c++ compiler optimize constant divisions by power-of-two value into shifts?

Question says it all. Does anyone know if the following... size_t div(size_t value) { const size_t x = 64; return value / x; } ...is optimized into? size_t div(size_t value) { return value >> 6; } Do compilers do this? (My interest lies in GCC). Are there situations where it does and others where it doesn't? I would re...

Floating point operations in GCC

Hello! Anyone knows where can I find the floating functions for non FPU processor (SH-3) called __mulsf3, __divsf3, __addsf3, __subsf3, __ltsf2 and __floatsisf. I read that those functions are in libgcc but linking against libgcc does not work. Also I read that SH3 devs moved those functions to another lib (maybe libfloat or libgcc_os)....

gcov warning: merge mismatch for summaries

Can anyone tell me what the gcov message "Merge mismatch for summaries" means? I have found the message in the gcc source here: http://www.opensource.apple.com/source/gcc/gcc-5646/gcc/libgcov.c It seems to be a sanity check that the tags in the .gcda files match, but I'm not sure. Anyone know how to work around this? ...

How to debug C program

Hi, I am using linux, gcc, c. I have a make file. I want to debug my module. How can I do it? I don't want to debug a single file, I want to debug the whole module. ...

Testing C++ program with Testing classes over normally used classes

Hi Guys, This will probably be a bot of a waffly question but ill try my best. I have a simple c++ program that i need to build testing for. I have 2 Classes i use besides the one i actually am using, these are called WebServer and BusinessLogicLayer. To test my own code i have made my own versions of these classes that feed dummy da...

invalid conversion from ‘char*’ to ‘char’

Hi Guys, I have a, int main (int argc, char *argv[]) and one of the arguements im passing in is a char. It gives the error message in the title when i go to compile How would i go about fixing this? Regards Paul ...