Is this program compliant? 
Author Message
 Is this program compliant?

Hi all,

Consider this program:

struct my_struct {
   void (*my_func)(struct my_struct *);
   unsigned char my_flag;

Quote:
};

void f (struct my_struct *a) {
   a->my_flag = 1;

Quote:
};

int main (void) {
   struct my_struct a;
   a.my_func = &f;
   a.my_flag = 0;
   a.my_func (&a);
   return 0;

Quote:
}

Is this code acceptable according to the C standard? What if the function f()
modified a->my_func instead of my_flag?

TIA,

Binand



Sun, 27 Jun 2004 18:00:01 GMT  
 Is this program compliant?

Quote:
> struct my_struct {
>    void (*my_func)(struct my_struct *);
>    unsigned char my_flag;
> };

> void f (struct my_struct *a) {
>    a->my_flag = 1;
> };

> int main (void) {
>    struct my_struct a;
>    a.my_func = &f;
>    a.my_flag = 0;
>    a.my_func (&a);
>    return 0;
> }

> Is this code acceptable according to the C standard? What if the function f()
> modified a->my_func instead of my_flag?

Yes, and yes, AFAICT. There is a sequence point just before the call to
the function, after the arguments, and AFAICT the function expression
itself as well, have been evaluated.

Richard



Sun, 27 Jun 2004 18:40:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. I am new to programming and am lost

2. I am not quite understand the program asks for

3. I am not quite understand the program asks for

4. how to do Multiuser programming? I am starter

5. I am interested in simulator programs

6. I am New to MFC : program structure question

7. i am programming...

8. Are const method parameters CLS compliant?

9. Newbie Question: How to Mark Class as CLS Compliant

10. Are unsigned types not CLS compliant?

11. CLR Compliant Method Signatures

12. Passing a byte array that is CLS compliant

 

 
Powered by phpBB® Forum Software