gcc

iphone run app as root

I am writing a gui wrapper for gcc for a jailbroken iphone, etc. and it is almost done. However, I get this output when it is run ld: can't open output file for writing : a.out, errno=1 collect2:ld return 1 exit status. I believe this has to do with the privelages the app runs with. I have tried the setuid trick in the cydia developer fa...

[MinGW] gcc: CreateProcess: No such file or directory

Hello, I am getting this error whenever I try to run GCC outside of it's installation directory (E:\MinGW\bin). So, lets say I am in E:\code and have a file called one.c. Running: gcc one.c -o one.exe will give me this error: gcc: CreateProcess: No such file or directory The only workaround is to navigate to it's installation direc...

Can I define variadic C preprocessor macros with __VA_ARGS in the middle instead of the end?

GCC complains if i do this: #define M(obj,met, ..., contents) obj##_##met(const void * self, __VA_ARGS__) { \ contents \ } Giving me these 2 reasons: error: missing ')' in macro parameter list warning: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro Apparently, C99 - style variadic macros expect the clos...

How to building a linux executable in CentOS 5 and running it on RedHat 9?

We had just migrated our software to CentOS 5 platform, from RedHat 9. We're now compiling our C programs on CentOS 5 using gcc v4.1.2 and everything works fine on CentOS, but these new binaries will not run on RedHat 9 anymore (kernel 2.4.1). Any suggestions on how we can compile a binary that can run on both of these platforms? ...

gcc optimizations cause app to fail

I'm having a real strange problem using GCC for ARM with the optimizations turned on. Compiling my C++ application without the optimizations produces an executable that at runtime outputs the expected results. As soon as I turn on the optimizations - that is -O1 - my application fails to produce the expected results. I tried for a cou...

Segfault in C++ calling virtual method on object created in pre-allocated buffer

Hmm... Title is a bit of a mouthful, but I'm really not sure which part of this is causing issues, I've run through it a ton of times, and can't pinpoint why... The idea is for a single Choice instance to be able to store any one value of any of the types passed in to it's template list... It's kind of like a union, except it keeps trac...

In Linux using C++ and GCC, is it possible to convert the virtual address to a physical address?

Under Linux, C++, and GCC, can I get a physical address for a given virtual address? I know I won't be able to manipulate the physical address as a physical address. ...

What is the safest way to run an executable on Linux?

I am trying to run a program compiled from C code from an unknown source. I want to make sure that the program does not harm my system in anyway. Like for instance, the program might have soemthing like system("rm -rf /") in the source, which is un-detectable, unless the code is thoroughly examined. I thought of the following 2 ways ...

Creating static library from C++ code and linking with iPhone SDK

I have written some code in C++ with a corresponding C interface (i.e C-function wrappers around the classes) that a friend wants to use in an iPhone application. Since I heard you can compile C++ for the plattform, but not use the iPhone sdk at the same time (sic) I thought that compiling all the code into a static library that my frie...

GCC forward declarations and __may__alias

I'm trying to forward declare a class with the _may_alias attribute, but GCC gives an error when I attempt to do so: struct __attribute__((__may_alias__)) MyType; MyType* foo(); typedef struct __attribute__((__may_alias__)) MyType { ... } MyType; MyType* foo() {} Gives the error: testc.c:4: error: redefinition of typedef ‘A’ ...

How would I make a pointer to an array of data work in C?

I have four arrays of data (3072 bytes each.) I want to point to one of these arrays, so if a function were passed a pointer to these arrays, it could manipulate them, and the pointers could be s So initially I thought of pointers-to-pointers: uint16_t *buffer0_level[BUFF_WORDS] FAR; uint16_t *buffer0_mask[BUFF_WORDS] FAR; uint16_t *bu...

Count number of parameters in C variable argument method call

When using va_start(), va_arg() and va_end() to read parameters passed to a method, is there a way to count how many arguments there are? According to the man page if you call va_arg() too many times you get "random errors": If there is no next argument, or if type is not compatible with the type of the actual next argument (as ...

Compound literals in MSVC

In GCC, I'm able to do this: (CachedPath){ino} inode->data = (struct Data)DATA_INIT; where: struct CachedPath { Ino ino; }; typedef int8_t Depth; struct Data { Offset size; Blkno root; Depth depth; }; #define DATA_INIT {0, -1, 0} MSVC gives the following error for these kind of casts: error C2143: syntax error : m...

Statically linking libraries in linux

I have an application which links to a number of libraries, most of them are available as both static as well as dynamic library on my machine. Below is the output of the ldd command. linux-gate.so.1 => (0xffffe000) libssl.so.0.9.8 => /usr/lib/libssl.so.0.9.8 (0xb782c000) libc.so.6 => /lib/libc.so.6 (0xb76cc000) libcrypto.so.0.9.8 => /...

Unresolved symbol on DLL loadup.

Hi, I am loading a DLL from an application and I want the DLL to be able to use a function implemented in the application. The definition of the function is put in a header and is included in the DLL. Can anyone tell me what I am doing wrong here or whether this can't be done? Thanks for any help. App: include <API.h> extern "C" in...

GCC left shift overflow

The following little program is very awkward using GCC version 4.2.1 (Apple Inc. build 5664) on a Mac. #include <stdio.h> int main(){ int x = 1 << 32; int y = 32; int z = 1 << y; printf("x:%d, z: %d\n", x, z); } The result is x:0, z: 1. Any idea why the values of x and z are different? Thanks a lot. ...

Runtime "symbol lookup error" when accessing libmysqlclient.so functionality in C

Context: I am not certain whether this is my problem or the problem of the server this is running on. I am trying to compile and run a small utility, to become a cron job, that uses the mysql libraries. The program compiles successfully with the following command, no errors or warnings: gcc my_program.c -o my_program -I /usr/include/mys...

Running a compiled C program on a shared hosting account?

Is it possible to run a compiled program on a shared hosting account?I dont think I have permission to run gcc, but I can compile it elsewhere and download it - would that work? ...

Forward declare FILE *

How do I forward declare FILE * in C? I normally do this using struct MyType;, but naturally this doesn't appear to be possible. If behaviour differs between C standards or compilers and with C++, this is also of interest. Update0 Why I want to do this aside: What I'm asking is how to forward declare a non-struct/"typedef'd struct" ty...

Allow for loop initialization in GCC and Clang when std={c,gnu}89?

How can I enable for loop initialization when compiling in c89 or gnu89 mode using GCC and Clang? ...