References to section numbers are to the C99 standard as found at http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf.
Item 3 of Sec 6.5.4 "Cast operators" says: "Conversion that involve...
Type: Posts; User: hzmonte
References to section numbers are to the C99 standard as found at http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf.
Item 3 of Sec 6.5.4 "Cast operators" says: "Conversion that involve...
<<split from 40936>>
If I call this offsetof() macro in a function:
int func([type] struct_name, [type] member)
{
...
x = offsetof(struct_name, member);
...
I inherit this piece of code:
struct LINK *link_id_search(int link_id)
{
struct LINK *link;
link = (LINK *) splaySearch(daemon_body.links, &link_id);
return link;
}
In that case, it would also achieve the same purpose if I write
#if (_XOPEN_SOURCE + 0 == 600)
, right?
I see in some header files, such as Sun's <sys/feature_tests.h>, the value of a macro is subtracted by zero before testing it against a value. Example:
#if (_XOPEN_SOURCE - 0 == 600) ||...
In most of the examples for callback functions I saw on the Web, the callback function is passed as a parameter of the caller function. Now, in payEmployee(), the callback function is pre-stored in a...
What do you mean by the representation of a pointer? Don't all pointers have the same size? And besides size, what are there in the representtaion?
I do not like what brewbuck suggests because...
int
dequeue_shared_queue(struct shared_queue *q, void **elem)
{
pthread_mutex_lock(&(q->access));
*elem = fifoQueueDequeue(q->queue);
pthread_mutex_unlock(&(q->access));
}
struct...
Can someone give an example? Is it the same as a callback function? Is a signal handler a hook function? Thx.
How about putting the solution(s) in the FAQ "How to ...?"
I know I am chewing up CPU resources, that's why the title is "How to WASTE CPU cycles in a program?" I do not mind that. I also know the speed of the computer will affect the amount of delay,...
I want the program to spend some time running but 'for ( ; ; )' is not suitable because I do not want it to run forever. I want something that I can kind of control how long it runs. That is, I want...
I inherited a middleware that already used SIGUSR1 for signalling a 'thread injection' and SIGUSR2 for some fault tolerance/checkpointing purposes.
POSIX defines only 2 user-defined signals. What if I need more than that?
I guess one way is use one of the less used signal, for example:
#define SIGUSR3 SIGWINCH
But which are the less...
It indeed does appear to have something to do with whether the variable in question is an int or a float.
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i,j,k;
int T;
int...
for (j=1; j<=3120; j++) {
for (i=1; i<=j-1; i++) {
T = 0.0;
for (k=1; k<=i-1; k++)
T += 0.0;
}
}
printf("T=%f\n", T);
I use gcc 3.4.1 (with -O3) on an AMD Opteron...
So, the state of a variable includes who is responsible for disposing it?
Even so, the memory deallocation of the item may not be the responsibility of the queue ADT. I may call dequeue() to get...
Assumed my_func() is called exclusively by pthread_create(). Which one of the following is better?
int my_func1(struct my_struct *x) {
// whole bunch of useful work
return result;
}
...
What is proper depends on your viewpoint. Let's say my_func(), in addition to being passed as a parameter of pthread_create(), is also called by some other function, and in the latter case, it is...
Correct me if I am wrong, declaring formal parameters to functions as const, if they should not be/is not changed, has 2 benefits;
1. It tells the program that calls this function that the parameter...
1. int my_func(struct my_struct *x) { ... }
ret = pthread_create(&tid, NULL, (void *(*)(void *))my_func, y);
2. void *my_func(void *xx) { struct my_struct *x = (struct my_struct *)xx; ... }
...
Thanks, quzah. The definition of my caller should have been:
void caller(void (*callee)(void *), void *arg) { ... }
One more question:
The prototype of pthread_create() is
int...
1. I have this piece of test code:
#include <stdio.h>
void callee(void *msg)
{
char *m = (char *)msg;
printf("%s\n", m);
}
On my Solaris 9 system, the prototype of the pthread_cleanup_push() function is, according to the man page:
void pthread_cleanup_push(void (*handler, void *), void *arg);
However, on my...
[/QUOTE]
That statement was first stated by King Mir. It was refuted by me before anyone else. (Actually quzah agreed to it in his/her June 16 3:17PM post.)
Maybe someone tried to explain that...