gcc

Ruby kernel commands

I am trying to execute the following command in irb, exec 'gcc j.cpp' but, i got the following error: /tmp/ccYhafBj.o: In function `main': j.cpp:(.text+0x14): undefined reference to `std::cout' j.cpp:(.text+0x19): undefined reference to `std::basic_ostream >iostream> using namespace std; int main() { cout << "Hello World"; r...

conversion to ‘size_t’ from ‘int’ may change the sign of the result - GCC , C

In my project I have turned on treat warnings as errors and compiling using the -pedantic and -ansi tags. I am using GCC compiler. In this project I have to use a third party source code which has got lot of warnings. Since I treat warnings as errors, I am having a tough time in fixing their code. Most of the warnings are about invalid...

stdin/stdout problem in gcc + rails

...

What does this compiler warning generated by `-pedantic` mean?

What does this GCC warning mean? cpfs.c:232:33: warning: ISO C99 requires rest arguments to be used The relevant lines are: __attribute__((format(printf, 2, 3))) static void cpfs_log(log_t level, char const *fmt, ...); #define log_debug(fmt, ...) cpfs_log(DEBUG, fmt, ##__VA_ARGS__) log_debug("Resetting bitmap"); The last line bei...

How to disable GCC warnings for a few lines of code

In Visual C++, it's possible to use #pragma warning (disable: ...). Also I found that in GCC you can override per file compiler flags. How can I do this for "next line", or with push/pop semantics around areas of code using GCC? ...

What exactly happens if you delete an object? (gcc) (When double-delete crashes?)

Please note that I don't want to solve any problem with my question - I was thinking about probabilities of things to happen and thus was wondering about something: What exactly happens if you delete on object and use gcc as compiler? Last week I was investigating a crash, where a race condition lead to an double delete of an object. ...

Experts - GCC and ld linker : re-initialization of variables contained in .data section?

In an C program, I need to re-initialize all global variables as they where when the program starts for tests purpose. I want to reproduce the data copy from Load Memory Address, LMA to VMA (run-time address) done by GCC libraries with a reinitialization function. For example, if foo variables are declared as global and initialized. And...

-L option not working for mingw gcc

I am trying to get mingw gcc to work. I need it to link with libopengl32.a. Said file exists in C:/mingw/lib. I used g++ as follows: g++ -L"C:/mingw/lib" main.o -o test.exe -llibopengl32.a It has no trouble finding the includes, it just complains that it can't find the library. It seems unable to find any other library as well. Al...

Using gcc/g++ instrument functions with MinGW?

Hello, i try to use the gcc instrument functions with g++ compiler of MinGW, but i always got linker issues. Is it possible to use the instrument functions with MinGW/MSYS? The linker failure output: $ g++ instrumentFunctions.cpp -o iftest -finstrument-functions >> iflog.txt C:/Users/HELLHO~1/AppData/Local/Temp/ccUwxrxt.o:instrumentFu...

How to hint to GCC that a line should be unreachable?

It's common for compilers to provide a switch to warn when code is unreachable. I've also seen macros for some libraries, that provide assertions for unreachable code. Is there a hint, such as through a pragma, or builtin that I can pass to GCC (or any other compilers for that matter), that will warn or error during compilation if it's ...

How to link a specific version of a shared library in makefile without using LD_LIBRARY_PATH?

Hi experts, I know that LD_LIBRARY_PATH is evil and it's a good habit to avoid using it. I have a program called server.c on a remote Solaris 9 server that holds two versions of openssl library (0.9.8 and 1.0.0) and I'm using gcc 3.4.6. My program need to link to 1.0.0a version. Because it's work environment, I don't have the right to m...

Static assert in C

What's the best way to achieve compile time static asserts in C (not C++), with particular emphasis on GCC? ...

Include header files from command line (gcc)?

Is it possible to specify extra header files to include from the command line (using GCC 4 / C++)? Or is there any other way files can be included except with #include? Background: I'm trying to compile a large code base on my own PC. The code is usually compiled in a cluster, with a complicated build system (SoftRelTools anybody?), wh...

MSVC: Implicit Template Instantiation, though templated constructor not used

Hello, I am trying to compile Flusspferd on Windows using MSVC, but it fails due to a template instantiation problem. For the ease of explanation I rewrote the problem in simpler terms: #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_convertible.hpp> class UndefinedType; class A { }; class TestClass { public: ...

How to determine the length of an array at compile time?

Are there macros or builtins that can return the length of arrays at compile time in GCC? For example: int array[10]; For which: sizeof(array) == 40 ???(array) == 10 Update0 I might just point out that doing this in C++ is trivial. One can build a template that returns the number inside []. I was certain that I'd once found a len...

C++ Overloaded Function Error

Hey everyone, I'm working with JNI on a current project, and am getting a strange error from my C++ code during compilation. I get an error stating: error: overloaded function with no contextual type information This is coming from the "nativegetsupportedciphersuites" line in the following array, which is mapping java functions with ...

MT6235 Linux porting.

Hi everybody. I'm trying to port uCLinux to my chinese phone. It's an MTK Phone based on mt6235 (ARM processor). Someone knows any hardware simulator for those kind of phone? and Where can I get the simulator? Many Thanks. Fran. ...

Getting control of std. streams in gcc

How can I get control of the stdin, stdout and stderr streams in gcc.?? We can redirect the error and output to separate files for sure, but is there a way that i can control the stdin such that whenever my program is executing and there is a moment when the stdin waits for a input(either from the user keyboard or any file), it sets a...

gcc, static library, external assembly function becomes undefined symbol

Hello everybody, I have a problem with g++ building an application which links to a static library, where the latter shall contain some global functions written in external asm-files, compiled with yasm. So in the library, I have #ifdef __cplusplus extern "C" { #endif extern void __attribute__((cdecl)) interp1( char *pSrc ); extern voi...

Are many static variables in functions using up to much memory?

Hi, I want to write a cross-plattform wrapper for some OS specific (Linux/MacOSX/Windows) calls to get the number of cores of the CPU etc. My idea was to put all of them in single functions with static variables, so stuff like the number of cores that does not change will be processed only once. int getNumCPUCores() { static int nu...