I am rewriting code to handle some embedded communications and right now the protocol handling is implemented in a While loop with a large case/switch statement. This method seems a little unwieldy. What are the most commonly used flow control methods for implementing communication protocols?
...
Is this function declaration in C#:
void foo(string mystring)
the same as this one in C:
void foo(char *)
i.e. In C#, does the called function receive a pointer behind the scenes?
...
How would you write (in C/C++) a macro which tests if an integer type (given as a parameter) is signed or unsigned?
#define is_this_type_signed (my_type) ...
...
What's the easiest way to get the filename associated with an open HANDLE in Win32?
...
I worked on an embedded system this summer written in straight C. It was an existing project that the company I work for had taken over. I have become quite accustomed to writing unit tests in Java using JUnit but was at a loss as to the best way to write unit tests for existing code (which needed refactoring) as well as new code added...
I have a lot of java background and am new to C. If the input integer is 11031, I want to count the number of 1's digits, how would I do this?
I know in java I can take the input as a String and use charAt, but I understand there is no implicit String function in C...
...
Hi,
I need to calculate Math.exp() from java very frequently, is it possible to get a native version to run faster than java's Math.exp()??
I tried just jni + C, but it's slower than just plain java.
...
I want to convert various location/date/times in history from GMT to local time. It seems that SystemTimeToTzSpecificLocalTime is better than FileTimeToLocalFileTime. When the date/time pairs also include various locations, the conversion gets hairy. I've found a data set at ftp://elsie.nci.nih.gov/pub/ that seems to be nicely complete ...
I want to write a small utility to call arbitrary functions from a C shared library. User should be able to list all the exported functions similar to what objdump or nm does. I checked these utilities' source but they are intimidating. Couldn't find enough information on google, if dl library has this functionality either.
(Clarificati...
What libraries do I have to pick from when working with Computer Vision in C/C++?
I realize that Google has a lot of good results, but maybe there's great libraries out there that it missed.
...
I want a user-privileged (not root) process to launch new processes as user "nobody". I've tried a straight call to setuid that fails with -1 EPERM on Ubuntu 8.04:
#include <sys/types.h>
#include <unistd.h>
int main() {
setuid(65534);
while (1);
return 0;
}
How should I do this instead?
...
I have some code with multiple very similar functions to look up an item in a list based on the contents of one field in a structure. The only difference between the functions is the type of the structure that the lookup is occurring in. If I could pass in the type, I could remove all the code duplication.
edit I just noticed that the...
Specifically:
When should we use it?
What is happening at the compiler/linker level that requires us to use it?
How in terms of compilation/linking does this solve the problems which require us to use it?
...
I sometimes need to modify OSS code or other peoples' code (usually C-based, but sometimes C++/Java) and find myself "grep"ing headers for types, function declarations etc. as I follow code flow and try to understand the system. Is there a good tool that exists to aid in code browsing. I'd love to be able to click on a type and be take...
How does the compiler know the prototype of sleep function or even printf function, when I did not include any header file in the first place.
Moreover, if I specify sleep(1,1,"xyz") or any arbitrary number of arguments, the compiler still compiles it.
But the strange thing is that gcc is able to find the definition of this funciton at ...
Can someone describe what a symbol table is in a C and C++ application?
...
Is it possible to delete a middle node in the single linked list when the only information available we have is the pointer to the node to be deleted and not the pointer to the previous node?After deletion the previous node should point to the node next to deleted node.
...
In most C or C++ environments, there is a "debug" mode and a "release" mode compilation.
Looking at the difference between the two, you find that the debug mode adds the debug symbols (often the -g option on lots of compilers) but it also disables most optimizations.
In "release" mode, you usually have all sorts of optimizations turned o...
I've recently started using Eclipse Ganymede CDT for C development and I couldn't like it more. I'm aware the learning curve could be sort of pronounced, therefore and with your help, my goal is to flatten it as much as possible. I'm looking for the best hacks, hints, tips, tricks, and best practices to really unleash the full power of t...
I am trying to populate a string with the double value using a sprintf like this
sprintf(S, "%f", val);
But the precision is being cut of to 6 decimal places.
I need about 10 decimal places for the precision.
Kindly tell me how that can be achieved.
...