c

Should Display Lists be cpu intensive?

My application is rendering about 100 display lists / second. While I do expect this to be intensive for the gpu, I don't see why it brings my cpu up to 80 - 90 %. Arn't display lists stored in the graphics card and not in system memory? What would I have to do to reduce this crazy cpu usage? My objects never change so that's why im usin...

Thinking in C++?

The programming language I use has been Java. I've been transitioning to C++ which has been somewhat rocky. The "rocky-ness" isn't in the learning but more along the lines of "Thinking in C++". I've seen many people say that you should learn C first (I technically know it already), and then I see people say no skip C and go straight to...

Setting and getting the values from configuration file.

Hi, I am using C language and Linux as my programming platform. In my sample application. I want to get and set the value of a custom configuration file. Below is the structure of my config file. idlevalue=5 sleeping=1 Now my problem is I am getting a hard time thinking how to implement the set functionality in my application. I am...

Associative array with mixed (numerical and string) indices?

How would one implement a dynamic associative array that could take any number of mixed indices (integers, strings, or both)? I aim to simulate structures by providing, for example, people[3].location as syntactical sugar for people[3, "location"]. How would you recommend representing this kind of array internally? By the way, I am usi...

OpenGL extensions causing linker problems

I'm trying to get the addresses for the VBO addon. In my stdafx.h I have the gl.h, glext.h and wglext.h If I do: glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB"); glGenBuffersARB(0,0); in stdafx.cpp, this will compile. but if I try to use glGenBuffersARB(0,0); in any of my other h or cpp f...

How to begin writing unit tests for a legacy Embedded C application - very tightly coupled modules?

I am currently working on a code base, that has never had any unit tests written on it. It has been written for a 16-bit Embedded processor, and I would like to start to add unit tests for all the code that I write, at a minimum and then extend this to other parts of the code. My problem with this is, I have found that each module (.c f...

sqlite: go to previous record in result set?

In SQLite, with the standard C interface -- is there an easy way (even if a bit hack-ish) to iterate backwards in the result set? I'm trying to avoid caching the results myself. A solution I thought about was executing an extra query that would return the reverse results, but I'm not sure how efficient it would be. ...

How to best turn on/off unit tests using #defines

I have a file with unit tests testOne() {...} testTwo() {...} ... but when I am troubleshooting I would like to turn off all except the unit test that is causing problems (due to massive amount of logging). At the moment I have done like this: #if 0 testOne() {...} #endif .. #if 1 testTroublesome() {...} #endif But I was wo...

Python subprocess module - unexpected behavior

Hi, I need to interface a C console program (as subprocess) with Python using stdin/stdout. the C program is more o less it: tmp = 0.0; printf("\ninput>>"); scanf_s("%f",&tmp); printf ("\ninput was: %f",tmp); tmp = 0.0; printf("\ninput>>"); scanf_s("%f",&tmp); printf ("\ninput was: %f",tmp); tmp ...

C: sprintf leads to SIGSEGV core via an strlen

Hi, My C application has the following two lines: char buf[1024]; sprintf(buf, "%s/game/rabbit/habit/cmd/talkPipe", getenv("APPLICATION_PATH")); The application sporadically crashes with SIGSEGV in the following manner: strlen(ff2ba231, 0, ffbfe1d0, 10, 7fff24d7, 0)+0x50 sprintf(ffbfe2a4, ff2ba231, 0, 74656400, 12, ff362ef2)+0x24 Ra...

File Reading issue in c++

I have the following program, int iIndex=0; char cPort[5]={"\0"}; char cFileChar; fopen_s(&fFile,"c:\\Config\\FileName.txt","r"); if(fFile !=0) { cFileChar = getc(fFile); while (cFileChar!= EOF) { cPort[iIndex]=cFileChar; iIndex++; cFileChar = getc(fFile); } iDIPort=atoi(cPort); } in the file I have 32000, but when...

How to correctly assign a new String value in C

Hi, i'm trying to understand how to solve this trivial problem in C in the cleanest/safest way: A simple String replacement. Here's my example: #include <stdio.h> int main(int argc, char *argv[]) { typedef struct { char name[20]; char surname[20]; int unsigned age; } person; //Here i can pass s...

Duplicate literals and hard-coding.

I see the follow pattern occurring quite frequently: b->last = ngx_cpymem(b->last, "</pre><hr>", sizeof("</pre><hr>") - 1); Notice that the literal string is used twice. The extract is from the nginx source-base. The compiler should be able to merge these literals when it is encountered within the compilation unit. My questions a...

How to return a pointer to a structure in ctypes?

Hi, I try to pass a pointer of a structure which is given me as a return value from the function 'bar' to the function 'foo_write'. But I get the error message 'TypeError: must be a ctypes type' for line 'foo = POINTER(temp_foo)'. In the ctypes online help I found that 'ctypes.POINTER' only works with ctypes types. Do you know of anothe...

How to 'catch' c printf in python with ctypes?

Hi there, I hope this is trivial and I just didn't find it in the tutorials. I am writing python code that 'supervises' c code, aka I run the c code with ctypes from python. Now I want to 'catch' the c 'printfs' to process the data that is output by the c code. Any idea how one would do this? Thanks ...

Is it possible for an application to take ownership of a window from another application?

Basically, I have two applications that run sequentially (second is started by the first, and the first exits immediately after.) I'd like to pass ownership of a window the first application created to the second application. The actual contents of the window don't need to be passed along, it's just being drawn in by DirectX. Alternativ...

gcc linker error: version node not found for symbol ...

Hi, I'm trying to build a shared library, and I get the following error: libavformat.so: version node not found for symbol av_dup_packet@LIBAVFORMAT_52 ld: failed to set dynamic section sizes: Bad value Does anybody knows what this error means? Host is i586-linux target is arm-linux Edit: Resolved, see comments ...

Linking... LINK : fatal error LNK1181: cannot open input file 'libgsl.a'

Hi, I am using SIFT algorithm code by Rob Hess which uses OpenCV library, in Windows. And I am having visual studio 2008 as the IDE. When I run the program for image matching having Debug as the Solution Configuration in VS There is no problem, everything works fine. But when i change the Solution Configuration to Release it gives a lin...

Is it possible for Visual C++ 2008 Express Edition to compile C source code?

I wish to learn C so that I can understand the concepts behind many major programming languages without the shortcuts that C++ has, or the garbage collectors that Java has. I plan on learning C and then going to C++, and I am currently studying Computer Science. In anycase, I was wondering if Visual C++ 2008 Express Edition compiler for...

Implicit typecasting in C (Converting 32 bit unsigned in to 8 bit u int)

My question looks a lot like http://stackoverflow.com/questions/2810280/how-to-store-a-64-bit-integer-in-2-32-bit-integers-and-convert-back-again (I have an unsigned 32 bit I need to put into 4 unsigned 8-bit variables in C) but My question is whether this: uint8_t a; uint32_t b; a = b; guarantees that a is filled with the eight r...