c

Run FreeBSD static binary on Linux ?

Would a very small/simple command line program, programmed in standards compliant C99, and statically compiled on FreeBSD work if executed on Linux ? (I would test this myself but I do not currently have a separate HDD to test on Linux.) ...

Use google translate to translate printf-based string

I'm trying to use the web-based google translate to translate my english files to another language. They contains characters like %s and %d. Is there a way to protect them from being erroneously translated. For instance, the text: Athlete already exists with number %s is translated to: Athlète existe déjà avec nombre% s whil...

Limit floating point precision?

Is there a way to round floating points to 2 points? ex: 3576.7675745342556 becomes 3576.76. Thanks ...

Why do certain things never crash whith debugger on?

My application uses GLUTesselator to tesselate complex concave polygons. It randomly crashes when I run the plain release exe, but it never crashes if I do start debugging in VS. I found this right here which is basically my problem: The multi-thread debug CRT (/MTd) masks the problem, because, like Windows does with processes sp...

Getting a subroutine to return three seperate arrays of random numbers in C

I currently have code for a subroutine to return a pointer to an array. This array is a list of random numbers for a one dimensional monte-carlo integral. I am now trying to do a multi dimensional equivalent which requires 3 arrays of random numbers and instead of having a separate subroutine for each I'm trying to make one which retur...

Some nice tutorial to introduce myself into the Telepathy API?

I would like to develop a bot for Empathy, but I don't know how to get started. I've read the Telepathy wiki, but I think it's very bad documented, does anybody know any nice tutorial? Better if it uses Python or C bindings. Thank you. ...

A way of debugging GLU with Visual Studio?

I'm using GLUTess to tesselate polygons. Sometimes it crashes with a null pointer issue and I have no way of knowing why since I just link to glu32.lib . Is there a way to see the source and get the exact line it crashes on? Thanks ...

Static linking GLU?

I'm using GLUTess to tesselate polygons. After several tests, I realized glu32.lib which links to glu32.dll, crashes every once in a while. Whereas GLU which I got from the opengl sdk, is solid as a rock. Unfortunately though, by not linking to the windows dll, this means I need to drag around GLU.dll with my app instead of relying on Wi...

Macro definitions for headers, where to put them?

When defining macros that headers rely on, such as _FILE_OFFSET_BITS, FUSE_USE_VERSION, _GNU_SOURCE among others, where is the best place to put them? Some possibilities I've considered include At the top of the any source files that rely on definitions exposed by headers included in that file Immediately before the include for the re...

Could someone help explain what this C one liner does?

I can usually figure out most C code but this one is over my head. #define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) an example usage would be something like: int x = 57; kroundup32(x); //x is now 64 A few other examples are: 1 to 1 2 to 2 7 to 8 31 to 32 60 to 64 3000 to 4096 ...

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...

#define LOG_MSG(...) for debugging

How does the following code work? #define ENABLE_DEBUG 1 #if ENABLE_DEBUG #define LOG_MSG printf #else #define LOG_MSG(...) #endif ...

Building a 3x3 reflection matrix using GSL

Based on the documents http://www.gnu.org/software/gsl/manual/html_node/Householder-Transformations.html and http://en.wikipedia.org/wiki/Householder_transformation I figured the following code would successfully produce the matrix for reflection in the plane orthogonal to the unit vector normal_vector. gsl_matrix * reflection = gsl...

Is this a valid C code?

Possible Duplicate: What does the code do? void duff(register char *to, register char *from, register int count) { register int n=(count+7)/8; switch(count%8) { case 0: do{ *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *t...

Function Argument declaration question from Programming in C, Stephen Kochan

I came across this code in Stephen G Kochan's book, Programming in c. Is this possible? float absolute_value(x) float x; { ----- ----- } So, as you can see, the argument x is declared after it's used it the method arguments. This throws an obvious compilation error in G++. So, which C compiler supports this? ...

In non-procedural languages, what specifies how things are to be done?

If you compare C vs SQL, this is the argument: In contrast to procedural languages such as C, which describe how things should be done, SQL is nonprocedural and describes what should be done. So, the how part for languages like SQL is specified by the language itself, is it? What if I want to change the way some query works. ...

Static assert in C

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

int versus unsigned char

Suppose we have a loop that runs for 100 times. Does using unsigned char instead of int for its counter make a difference? And also using i += 1U instead of i++? Or do compilers take care of that? ...

typedef stuct problem in C

Hello there I am facing a weird problem I have defined I a structure in a C header file: typedef struct iRecActive{ char iRecSID[32]; unsigned char RecStatus; int curSel; }iRecAcitve_t; but when I use the same structure in another file, the compiler doesn't recognize the structure even though I have double checked that...

how to find that is there any loop exist in the link list using two pointers?

Possible Duplicate: How to determine if a linked list has a cycle using only two memory locations. hello i have been asked in an interview that how can i find a loop exists in a link list using only two pointers. i have done the following: 1) find the center of the link list each time 2) by iterating this at the end both th...