c

Does anybody have any experience with SSEPlus?

SSEPlus is an open source library from AMD for unified handling of SSE processor extensions. I'm considering to use this library for my next small project and would like to know, if anybody have experience with it? Can I use it on Intel machines? Any performance issues in comparison to direct SSE calls? Any issues on 64bit machines? Wha...

How do I create a Python class in C?

I have a legacy C library that creates a tree of objects. I would like to convert the tree into a pre-existing Python class. How do I create the PyObject for that class? ...

How to get rid of GVim folding comments in your code?

There is someone in my team that swears by using some kind of GVim feature to do manually code folding. As I'm using another editor and do not really need the folding feature, I think it only pollutes the source code with tags like: /* {{{1 */ Convincing the person not to use this folding is not an option (got into some heated discus...

What is a lightweight cross platform WAV playing library?

I'm looking for a lightweight way to make my program (written in C) be able to play audio files on either windows or linux. I am currently using windows native calls, which is essentially just a single call that is passed a filename. I would like something similar that works on linux. The audio files are Microsoft PCM, Single channel...

Assignment Makes Pointer from Integer Without a Cast

I have an Obj-C method similar to this: -(void)getUserDefaults:(BOOL *)refreshDefaults { PostAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; if (refreshDefaults) { [appDelegate retrieveDefaults]; } } When I call it like this I get no warning: [self getUserDefaults:NO]; When I call it like ...

Network interface settings

How can we get the network interface name (i.e. the one that appears in the "Network connections" dialog) given the device description (i.e. the string that appears in the "Device Properties -> Connect using:" textbox)? We must do it in pure C/C++ language, or through some of the standard command line tools (e.g. netsh, ipconfig...), or ...

How can I read an XML file into a buffer in C?

I want to read an XML file into a char *buffer using C. What is the best way to do this? How should I get started? ...

In C arrays why is this true? a[5] == 5[a]

As Joel points out in Stack Overflow podcast #34, in C Programming Language (aka: K & R), there is mention of this property of arrays in C: a[5] == 5[a] Joel says that it's because of pointer arithmetic but I still don't understand. Why does a[5] == 5[a] ? Edit: The accepted answer is great. For a lower level view of how this works, se...

C/objC/C++/Java compilers

I downloaded NetBeans (for first time) to use Java and found that it can handle C/C++ etc too. Wanted to know following -- 01- Is there any better C++ tool (IDE) other than NetBeans and MS Visual Studio? Better means very mature and popular (and free). 02- What is the difference between GNU Java and Sun Java compilers? 02- Is there...

Why do compilers not warn about out-of-bounds static array indices?

A colleague of mine recently got bitten badly by writing out of bounds to a static array on the stack (he added an element to it without increasing the array size). Shouldn't the compiler catch this kind of error? The following code compiles cleanly with gcc, even with the -Wall -Wextra options, and yet it is clearly erroneous: int ma...

What is the best way to implement a cross-platform, multi-threaded server in C/C++?

Part of the development team I work with has been given the challenge of writing a server for integration with our product. We have some low-level sensor devices that provide a C SDK, and we want to share them over a network for use by people collecting data. Sounds simple, right? Someone would connect a sensor device to their machine in...

Intersection of two lines defined in (rho/theta ) parameterization

Have created a c++ implementation of the Hough transform for detecting lines in images. Found lines are represented using rho, theta, as described on wikipedia: "The parameter r represents the distance between the line and the origin, while θ is the angle of the vector from the origin to this closest point " How can i find the inte...

Creating a module system (dynamic loading) in C

How would one go about loading compiled C code at run time, and then calling functions within it? Not like simply calling exec(). EDIT: The the program loading the module is in C. ...

How to signal select() to return immediately?

I have a worker thread that is listening to a TCP socket for incoming traffic, and buffering the received data for the main thread to access (let's call this socket A). However, the worker thread also has to do some regular operations (say, once per second), even if there is no data coming in. Therefore, I use select() with a timeout, so...

How do I retrofit a GUI to an existing C program?

I've been working on a project of porting an old solaris CL program to run on Linux, and barring some unrelated hardware issues, that's finished. Now I want a GUI for it, so the user can choose among the various options with drop downs and check boxes, as well as some text input areas for options that aren't so restricted, like the filen...

Error handling in C code

Hi! What do you consider "best practice" when it comes to error handling errors in a consistent way in a C library. There are two ways I've been thinking of: Always return error code. A typical function would look like this: MYAPI_ERROR getObjectSize(MYAPIHandle h, int* returnedSize); The always provide an error pointer approach: ...

Get signatures of exported functions in a DLL

Is it possible to get an exported (C style?) function's signature (parameter count/types, return type) from a DLL? I can view the list of function names, addresses, ordinals, etc. with DLL Export Viewer but I can't view the signatures. I only have the dll file and don't have neither .h nor .def files. UPDATE: Using a tool called API Mon...

Example C Function using volatile variables

Hi, for a paper I'm looking for an real-life C function which uses volatile variables. That in itself is not hard to find, but I am looking for a function in which the value of the volatile variable must change during the course of the execution of the function, for a particular branch of the function to be reached. Something like thi...

Tool to determine symbol origin in C

I'm looking for a tool that, given a bit of C, will tell you what symbols (types, precompiler definitions, functions, etc) are used from a given header file. I'm doing a port of a large driver from Solaris to Windows and figuring out where things are coming from is getting to be difficult, so this would be a huge help. Any ideas? Edit...

C Symmetric Stream Cipher

Does anyone have a good implementation of a stream cipher written in pure portable C? I am not terribly concerned with the strength of the cipher at this point in time because it is only for a proof of concept, but speed would be important. I've thought about just Xor'ing with a constant if I cannot find a decent stream cipher. ...