gcc

Trying to compile Python using TDM-GCC on Win32, error in posixmodule.c

This is the line typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv, LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags ); Where I get the error: Python-2.6.4\Modules\posixmodule.c|8299|error: expected ')' before '*' token| The compiler is GCC: gcc (TDM-1 mingw32) 4.4.1...

How do you set the order of libraries in automake?

How do you set the order of libraries in automake? In my am file I have something like: myprog_DEPENDENCIES = adhoc-target myprog_SOURCES = myprog.c myprog_LDADD = libmine.la myprog_LFLAGS = -static -L/home/user/lib -ladhoc Now, when I compile I get this compile line similar too: gcc -static myprog-myprog.o -o myprog -L/home/user/li...

Avoid linking to libstdc++

I'm working on an embedded project that currently uses C in Linux and uClibc. We're interested in moving it to C++, but I don't want the overhead associated with linking in libstdc++. My impression is that this is possible provided we don't use anything from STL, such as iostream or vector. How does one direct g++ to compile without li...

Dynamic memory allocation on stack

I recently tried this experiment in which instead of going for dynamic memory allocation for memory requirements of unknown size, I did a static allocation. When an array a[i] was declared by me, I kept i (size of the array) variable and dependent on the input that the user gives. #include <stdio.h> #include <stdlib.h> #include <stri...

Why might using a "long long" in C or C++ be a bad thing?

Why might using a "long long" in C or C++ be a bad thing? I was compiling a runtime library the other day and in the code it checks to see if longs are 64bits and if not it uses a long long. But along with that, it sends out a #warning "using long long". I can't think of any reason for the "long long" being a warning unless it was lefto...

How to build an application that requires both libstdc++.so.5 and libstdc++.so.6?

I want to preface this with the important notice that I am not a C/C++ programmer, and know very little about how linkage of libraries works in C. Our code uses libstdc++.so.6 (gcc 3.4, i think). We have third-party precompiled (closed source) libraries that use libstdc++.so.5 (gcc 2.something or 3.2, i think). This is on linux. We h...

How to embed gcc and gcov command in expect script

Hi, I wanted to embed gcc and gcov command as part of expect script.. I tried as.. #!/usr/bin/expect -f send ":gcc -fprofile-arcs -ftest-coverage c.c\r" send ":gcov c.c\r" But it doesnt run and execute the commands. Any insights to this? Thanks. ...

Where is stdbool.h?

I want to find the _Bool definition on my system, so for systems where it's missing I can implement it. I've seen various definitions for it here and on other sites, but wanted to check on the system for the definitive definition. Slight problem, in that I can't find where _Bool is defined or even stdbool.h mussys@debmus:~$ find /usr/i...

How are C++-style comments handled in GCC 4.3.3 by default?

I'm using GCC 4.3.3 on Ubuntu 9.04 64-bit and was getting errors using C++-style comments in C code. When I say "by default" in the title, I mean simply invoking gcc test.c According to the GCC 4.3.3 docs (here), this is supported...yet I got the errors anyway. These errors went away with a simple -std=c99 addition to my compile string...

Conversion problem

I'm using gcc 4.3.2. I have the following code (simplified): #include <cstdlib> template<int SIZE> class Buffer { public: explicit Buffer(const char *p = NULL) {} explicit Buffer(const Buffer &other); const char *c_str() const { return m_buffer; } private: char m_buffer[SIZE]; }; typedef Buffer<10> A; typedef Buffer...

How to reduce compilation cost in GCC and make?

I am trying to build some big libraries, like Boost and OpenCV, from their source code via make and GCC under Ubuntu 8.10 on my laptop. Unfortunately the compilation of those big libraries seem to be big burden to my laptop (Acer Aspire 5000). Its fan makes higher and higher noises until out of a sudden my laptop shuts itself down withou...

Can likely/unlikely macros be used in user-space code?

I came across these 2 macros in Linux kernel code. I know they are instructions to compiler (gcc) for optimizations in case of branching. My question is, can we use these macros in user space code? Will it give any optimization? Any example will be very helpful. ...

Scanf skips every other while loop in C

I'm trying to develop a simple text-based hangman game, and the main game loop starts with a prompt to enter a guess at each letter, then goes on to check if the letter is in the word and takes a life off if it isn't. However, when I run the game the prompt comes up twice each time, and the program doesn't wait for the user's input. It a...

Help needed for wxWidgets - DialogBlocks

I'm using DialogBlocks to build a dialog and got the errors below * g++ i386: No such file or directory * cclplus: error: unrecognized command line option -arch" make * [GCCRelease/AdvancedControls:0] I really don't know what does that mean. By the way, I'm a new learner on this field, any effort is greatly appreciated. Many ...

What does %c mean in GCC inline assembly code?

I am trying to understand this inline assembly code which comes from _hypercall0 here. asm volatile ("call hypercall_page+%c[offset]" \ : "=r" (__res) \ : [offset] "i" (__HYPERVISOR_##name * sizeof(hypercall_page[0])) \ : "memory", "edi", "esi", "edx", "ecx", "ebx", "eax") I am having trouble finding informatio...

How to compile a 32-bit binary on a 64-bit linux machines without touching the CFLAGS environment variable

The solution in http://stackoverflow.com/questions/1272357/how-to-compile-a-32-bit-binary-on-a-64-bit-linux-machine-with-gcc-cmake is not possible because i use 3rd party software and other stuff which is using the CFLAGS variable already. And patching their makefiles is not allowed - says my boss. So i have to find another way to enf...

C/C++ compiler feedback optimization

Has anyone seen any real world numbers for different programs which are using the feedback optimization that C/C++ compilres offer to support the branch prediction, cache preloading functions etc. I searched for it and amazingly not even the popular interpreter development groups seem to have checked the effect. And increasing ruby,py...

NULL definition problem on 64 bit system

I'm running on RHEL 5.1 64 bit platfrom using gcc 4.1.2. I have a utility function: void str_concat(char *buff, int buffSize, ...); which concats char * passed in variadic list(...), while last argument should be NULL, to designate end of the arguments. On 64 bit system NULL is 8 bytes. Now to the problem. My application includes di...

Datastructure alignment.

So, I'm coding some packet structures (Ethernet, IP, etc) and noticed that some of them are followed by attribute((packed)) which prevents the gcc compiler from attempting to add padding to them. This makes sense, because these structures are supposed to go onto the wire. But then, I counted the words: struct ether_header { u_int8_t...

is there a way to look at the preprocessor expanded file in C

Hi i want to know how could we look at the c file after it has been expanded by the preprocessor before compilation with all the macro values put in the code inside the function where ever they are used. in there a way to do it? ...