gcc

Makefile automatic link dependency ?

It's easy to let program figure out the dependency at compile time, (with gcc -MM). Nevertheless, link dependency (deciding which libraries should be linked to) seems to be difficult to figure out. This issue become emergent when multiple targets with individual libraries to link to are needed. For instance, three dynamic library target...

Did someone port uw imap c-client to iPhone OS (device)?

I downloaded the source code, typed 'make oxp' then I got a file named 'c-client.a', I think it is for X86. But how can I build this library for iPhone OS (device)? ...

How do I get an Iterator over a vector of objects from a Template?

I'm busy implementing a Graph ADT in C++. I have templates for the Edges and the Vertices. At each Vertex I have a vector containing pointers to the Edges that are incident to it. Now I'm trying to get an iterator over those edges. These are the lines of code: vector<Edge<edgeDecor, vertexDecor, dir>*> edges = this->incidentEdges(); vec...

Is there a Visual C++ equivalent to gcc --kill-at?

Namely, a DLL name has an extra @8 at the end which is causing trouble. Apparently, using the --kill-at flag in gcc would solve this, but I can't find any similar suggestions for MSVC. EDIT: A little more info: I'm trying to get a C++ JNI dll to work, but I constantly get Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: ...

Alternate format specifiers for long long in C

Is there any other (alternative) format specifiers for long long in C other than %lld which can be safely used in scanf under gcc? I am aware that %lld does it's job fine; I am just inquisitive :-) ...

How does 64 bit code work on OS-X 10.5?

I initially thought that 64 bit instructions would not work on OS-X 10.5. I wrote a little test program and compiled it with GCC -m64. I used long long for my 64 bit integers. The assembly instructions used look like they are 64 bit. eg. imultq and movq 8(%rbp),%rax. I seems to work. I am only using printf to display the 64 bit value...

Returning a dynamically created array from function

I'm trying to create a function that would dynamically allocate an array, sets the values of the elements, and returns the size of the array. The array variable is a pointer that is declared outside the function and passed as a parameter. Here is the code: #include <cstdlib> #include <iostream> using namespace std; int doArray(...

going reverse in a for loop?

Hello there, Basically i got this for loop and i want the number inputed (eg. 123) to be printed out in reverse, so "321". so far it works fine and prints out the correct order when the for loop is for(i = 0; i<len ; i++) but i get an error when i try to print it in reverse?. Whats going wrong? #include <stdio.h> #include <string.h>...

gcc error: Can't create precompiled header

I have some useful typedefs on a header file called utypes.h. I have decided to use make and haven't found a way to compile it since then. When I execute gcc -Wall -c utypes.h to generate the .o object of utypes I get the following error: "utypes.h:1 fatal error: can't create precomiled header types.h.gch: Permission Denied (EACESS) C...

ASM x86 relative JMP

Hi, I'm doing some ASM code in a C code with the asm function. My environment is DVL with gcc version 3. Hi need to make a JMP to a relative address like %eip+0x1f. How can I do this ? Thanks ...

GCC emits extra code for boost::shared_ptr dereference

I have the following code: #include <boost/shared_ptr.hpp> struct Foo { int a; }; static int A; void func_shared(const boost::shared_ptr<Foo> &foo) { A = foo->a; } void func_raw(Foo * const foo) { A = foo->a; } I thought the compiler would create identical code, but for shared_ptr version an extra seemingly redundant instru...

Calling assembly in GCC?

#include <stdlib.h> static inline uint xchg(volatile unsigned int *addr, unsigned int newval) { uint result; asm volatile("lock; xchgl %0, %1" : "+m" (*addr), "=a" (result) : "1" (newval) : "cc"); return result; } Can some one tell me what this code does exactly? I mean I have an idea or the parts of this command. "1" newva...

Strange behaviour with fputs and a loop.

When running the following code I get no output but I cannot work out why. # include <stdio.h> int main() { fputs("hello", stdout); while (1); return 0; } Without the while loop it works perfectly but as soon as I add it in I get no output. Surely it should output before starting the loop? Is it just on my system? Do I...

Why does gcc add symbols to non-debug build?

When I do a release build with gcc (i.e. I do not specify -g), I still seem to end up with symbols in the binary, and have to use strip to remove them. In fact, I can still breakpoint functions and get backtraces in gdb (albeit without line numbers). This surprised me - can anyone explain why this happens? e.g. #include <stdio.h> sta...

Why does gcc think that I am trying to make a function call in my template function signature?

GCC seem to think that I am trying to make a function call in my template function signature. Can anyone please tell me what is wrong with the following? 227 template<class edgeDecor, class vertexDecor, bool dir> 228 vector<Vertex<edgeDecor,vertexDecor,dir>> Graph<edgeDecor,vertexDecor,dir>::vertices() 229 { 230 return V; 231 }; GCC i...

How do I edit error messages in GCC source

Hi, I am trying to create a C Compiler in my native language which I intend to put up as open source. I want to do this by downloading the GCC source code and then manually translating the error messages and warnings into my target language. I am a beginner to GCC. Any idea where the error messages are located in the source code and how ...

Why won't C++ allow this default value

Why won't GCC allow a default parameter here? template<class edgeDecor, class vertexDecor, bool dir> Graph<edgeDecor,int,dir> Graph<edgeDecor,vertexDecor,dir>::Dijkstra(vertex s, bool print = false) const { This is the output I get: graph.h:82: error: default argument given for parameter 2 of ‘Graph<edgeDecor, int, dir> Graph<edge...

ICC vs GCC - Optimization and CPU architecture

Hi all, I'm interested in knowing how GCC differs from Intel's ICC in terms of the optimization levels and catering to specific processor architecture. I'm using GCC 4.1.2 20070626 and ICC v11.1 for Linux. How does ICC's optimization levels (O1 to O3) differ from GCC, if they differ at all? The ICC is able to cater specifically to dif...

What is the environment variable for GCC/G++ to look for .h files during compilation

Hi, Can you please tell me if there is an environment variable for GCC/G++ to look for .h files during compilation? I google my question, there are people say LIBRARY_PATH, C_PATH, C_INCLUDE_PATH, CPLUS_PATH, so which one is it? Thank you. ...

What makes this "declarator invalid"? C++

I have Vertex template in vertex.h. From my graph.h: 20 template<class edgeDecor, class vertexDecor, bool dir> 21 class Vertex; which I use in my Graph template. I've used the Vertex template successfully throughout my Graph, return pointers to Vertices, etc. Now for the first time I am trying to declare and instantiate a Vertex obje...