c

What is g++-3 / gcc-3?

Trying to use make from cygwin using g++ I was getting Access Denied error messages. Googling the error message I found a positing referring to g++-3 and gcc-3 http://www.linuxquestions.org/questions/linux-software-2/cygwin-g-3-exe-gcc-3-exe-corrupted-to-g-3-exe-dam-and-gcc-3-exe-dam-769722/)... Changing the compiler to g++-3 seems ...

How to make a PHP extension

I know you can technically make PHP extension just by making a PHP file and using require_once. But would it optimize the performance if you wrote an extension in C or C++. If so, how would you make a "hello-world" for that? ...

How does linux synchronize preempt count

http://lxr.linux.no/linux+v2.6.35/include/linux/preempt.h#L21 I am just trying get the linux source. I saw this preempt count and how does linux ensure the preempt count is atomic ? The code just increments the value. Also I have an another question. why does interrupt handles need to maintain mutual exclusion. Because only one can exe...

Proper way to pan and move camera in OpenGL?

Right now I'm panning by glRotating before rendering everything, and i'm moving the camera by gltranslating. I feel as if this is wrong since im essentially moving the scene, not the camera. What is the proper way to move the camera? Thanks ...

please help making strstr()

I have made strstr() function but the program does not give any output,just a blank screen.Please have a look at the code. #include<stdio.h> #include<conio.h> const char* mystrstr(const char *str1, const char *str2); int main() { const char *str1="chal bhai nikal"; const char *str2="nikal",*result; r...

Unknown C expression

Hi - I ran across the following line in an example program, and don't know what it is. I imagine it's a function call, but am not sure: (void) pthread_mutex_init(&bottleneck, &mxattr); If it is a function call, why is it preceded with (void)? I've never seen that before. Here's the line in more context: attr_init(pthread...

Is this Project Euler #5 solution more efficient than a known one?

Here's my solution to Project Euler problem #5: #include <stdio.h> #include <stdint.h> #define N 20 int main( int argc, char* argv[] ) { uint64_t r = 1; uint64_t i, j; for( i = 2; i <= N; ++i ) if( (j = r%i) ) r *= ( (i%j) ? i : (i/j) ); printf( "\n%llu\n", r ); return 0; } It is of O(n) efficiency. ...

Segmentation fault on recv()

I am writing client/server programs on Unix in C, using send/recv. I am occasionally getting a segmentation fault from a recv call. The behavior is not perfectly reproducible; sometimes it happens, and sometimes the program runs to completion. Any ideas what this could mean? ...

C Macro Token Concatenation involving a variable - is it possible?

Hello, I'm trying to define a macro to generate a token name, containing a variable. Basically, what I'm trying is this: #define GLUER(x,y,z) x##y##z #define PxDIR(x) GLUER(P,x,DIR) int main() { int port; port = 2; PxDIR(port) |= 0x01; } I'm hoping to generate the token P2DIR in the above statement, but according to my compile...

Largest representable negative floating-point number

What is a platform-independent way of specifying the largest representable negative floating-point number? We found an algorithm that broke when run on a PS3's SPU, but worked fine when compiled for the PPU: float x = -FLT_MAX; /* stuff */ if (x > 0.0f) { // If x is unchanged, code is executed on SPU } Essentially, is there a wel...

append items to an array with a macro, in C

Hi, i have an array (C language) that should be initialized at compile time. For example: DECLARE_CMD(f1, arg); DECLARE_CMD(f2, arg); The DECLARE_CMD is called from multiple files. I want this to be preprocessed in. my_func_type my_funcs [] = { &f1, &f2 } It is possible, with a macro, to append items to an static array? I...

EM_GETLINE error C++ Get last Line from Textbox

Hello ! I'm having a minor problem with EM_GETLINE. I have a textbox I want to extract the text from. The box keeps updating all the time (it's a log file thet keeps updating, last message at the bottom). All I want is that very last line. My code: HWND hwnd = (HWND)0x00020A72; TCHAR param[1000]; char display[1000]; LONG lR...

Does endianness have an effect when copying bytes in memory?

Am I right in thinking that endianess is only relevant when we're talking about how to store a value and not relevant when copying memory? For example if I have a value 0xf2fe0000 and store it on a little endian system - the bytes get stored in the order 00, 00, fe and f2. But on a big endian system the bytes get stored f2, fe, 00 and ...

How to copy array of struct in C

I have defined struct like typedef struct { char *oidkey; int showperf; char oidrealvalue[BUFSIZE]; char *oidlimits; } struct_oidpairs; and I have array of struct struct_oidpairs b[] ={{.....},....} and I want to copy it to new struct array a[] please help ...

What is the use of second structure(*oldact) in sigaction()

Hi, I am trying to create a handler for the exit signal in c and my operating system is ubuntu. I am using sigaction method to register my custom handler method. int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); Here's my code #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signa...

What is the use of ## preprocessor in C.

Possible Duplicate: C preprocessor and concatenation can anybody explain with example ? ...

Short circuit evaluation and side effects

OK, I'm a little embarassed to ask this question, but I just want to be sure... It is known that C uses short circuit evaluation in boolean expressions: int c = 0; if (c && func(c)) { /* whatever... */ } In that example func(c) is not called because c evaluates to 0. But how about more sophisticated example where side effects of comp...

what is the Rvalue and Lvalue in c

Possible Duplicates: What are rvalues, lvalues, xvalues, glvalues, and prvalues? lvalue and rvalue difference between c's expression and c++'s expression On executing the program below, I got error an message like "required Lvalue is missing in main function" main() { int i; printf("%d",++i++); } Please tell me ...

Possible to #if or #ifdef based on preprocessor-generated "thing"

I'm trying to engage in some C-preprocessor-only templating efforts in order to type-specialize some code. I've tried to boil it down a bit, so this example seems trivial and pointless, but the real challenge is getting the "include" blocking. Say I have a "template" file, that gets #included from other source files that define T_ELEME...

Creating array of 2d arrays

I have a number of arrays double foo[][2] = { {1.0,3.0}, {2.6,10.0}, {0.0,0.0} }; double bar[][2] = { {1.4,3.2}, {2.1,9.9}, {2.1,9.9}, {2.1,9.9}, {0.0,0.0} }; So these are both of type: double (*)[2] I want to make an array of these so I need to declare an array of type pointer to array[2] double ((*array)[2])[] = {foo, bar}; Th...