If you have a particular line of C code in mind to examine in the machine output, how would you locate it in objdump output. Here is an example
if (cond)
foo;
bar();
and I want to see if bar was inlined as I'd like.
Or would you use some alternative tool instead of objdump?
...
Of course, the immediate answer for most situations is "yes", and I am a firm believer that a process should correctly cleanup any resources it has allocated, but what I have in my situation is a long-running system daemon that opens a fixed number of file descriptors at the startup, and closes them all before exiting.
This is an embedd...
How do I do the above? There is mktime function but that treats the input as expressed in local time but how do i perform the conversion if my input tm variable happens to be in UTC.
...
Hi all ,
I am coding a basic traffic light control which will be displayed on the monitor.
In that i need an external interrupt (event ) to happen and change the state of the current traffic light. I am trying to do it without any board or external peripheral.
Now I think i have the following choices . tell me which is the best.
1. One ...
I am an intermediate C programmer. If you have made any coding mistake that you came to know later that it was the most hazardous / harmful to the total application please share that code or description. I want to know this because in future I may come across such situations and I want to have your advice to avoid such mistakes.
...
According to MSDN
The return value specifies the result
of the message processing; it depends
on the message sent.
I know it is defined as
typedef LONG_PTR LRESULT;
Meaning it will be 8 bytes on 64bit machine but (!) ....
Does anyone know if it is safe to assume that only the lower 4 bytes are used and store it as an IN...
I have a dll that must be useable from C etc, so I cant use string objects etc as a normal would, but I'm not sure on how to do this safely..
const char *GetString()
{
std::stringstream ss;
ss << "The random number is: " << rand();
return ss.str().c_str();
}
could the c string be destroyed when ss falls off the stack? I'm ...
What are best practices with regards to C and C++ coding standards? Should developers be allowed to willy-nilly mix them together. Are there any complications when linking C and C++ object files.
Should things like socket libraries that traditionally is written in C remain in C and kept in seperate source files? That is keeping c code...
Suppose I have a process which spawns exactly one child process. Now when the parent process exits for whatever reason (normally or abnormally, by kill, ^C, assert failure or anything else) I want the child process to die. How to do that correctly?
Some similar question on stackoverflow:
(asked earlier) http://stackoverflow.com/ques...
Hello,
I am trying to store a large amount of boolean information that is determined at run-time. I was wondering what the best method might be.
I have currently been trying to allocate the memory using:
pStatus = malloc((<number of data points>/8) + 1);
thinking that this will give me enough bits to work with. I could then refer...
I am working on an embedded application where the device is controlled through a command interface. I mocked the command dispatcher in VC and had it working to my satisfaction; but when I then moved the code over to the embedded environment, I found out that the compiler has a broken implementation of pointer-to-func's.
Here's how I or...
I want to write a small program that should print something like
testing CPU... done
testing RAM... done
and so on.
I wrote the following program in C:
printf( "testing RAM...\t\t" );
sleep( sleep_time );
printf( "done\n\n" );
printf( "testing HDD...\t\t" );
sleep( sleep_time );
printf( "done\n\n" );
where sleep_time i...
I have a client application that connects to the MySQL database 4 server using stock libraries on SuSE SLES 9. However, at times when processing a particular reset set from the server, iterating throw the results does not allow me to process all the results that is in the database.
This issue happens sometimes, mostly when servers hav...
I have some global variables in a Python script. Some functions in that script call into C - is it possible to set one of those variables while in C and if so, how?
I appreciate that this isn't a very nice design in the first place, but I need to make a small change to existing code, I don't want to embark on major refactoring of existi...
I have two C DLLs that I need to access in the same executable. I have header files and .LIB files for both libraries. Unfortunately a subset of the functions that I need to access have the exact same names. The best solution I have been able to come up with so far is to use LoadLibrary to load one of the DLLs and explicitly call its met...
while (xxx) {
timeout.tv_sec=TIMEOUT;
timeout.tv_usec=0;
FD_ZERO(&set);
FD_SET(sd,&set);
switch (select(FD_SETSIZE,&set,NULL,NULL,&timeout))
xxxxx
}
works fine, however
FD_ZERO(&set);
FD_SET(sd,&set);
while (xxx) {
timeout.tv_sec=TIMEOUT;
timeout.tv_usec=0;
switch (select(FD_SETSIZE,&set,NULL,N...
Hey there guys, the question is actually about stack overflows in C.
I have an assigment that I can not get done for the life of me, i've looked at everything in the gdb and I just cant figure it.
The question is the following:
int i,n;
void confused()
{
printf("who called me");
exit(0);
}
void shell_call(char *c)
{
prin...
typedef struct {
nat id;
char *data;
} element_struct;
typedef element_struct * element;
void push(element e, queue s) {
nat lt = s->length;
if (lt == max_length - 1) {
printf("Error in push: Queue is full.\n");
return;
}
else {
s->c...
I have a C library with numerous math routines for dealing with vectors, matrices, quaternions and so on. It needs to remain in C because I often use it for embedded work and as a Lua extension. In addition, I have C++ class wrappers to allow for more convenient object management and operator overloading for math operations using the C A...
I have to read a txt file with lines formated like this:
1: (G, 2), (F, 3)
2: (G, 2), (F, 3)
3: (F, 4), (G, 5)
4: (F, 4), (G, 5)
5: (F, 6), (c, w)
6: (p, f), (G, 7)
7: (G, 7), (G, 7)
w: (c, w), (c, w)
Each line will feed a struct with its data (the 5 numbers or letters in it).
What's the best way to read the line and get the strings ...