Same name structure with different definition in C -


is allowed use same name structure different definitions in 2 different c files in same project. eg.

file1.c

typedef struct {     unsigned int unvar;               } abc; 

file2.c

typedef struct {     int var; } abc; 

abc used in both files. when compile these file part of same project there no errors, want understand whether correct usage.

6.7.2.1 structure , union specifiers

  1. the presence of struct-declaration-list in struct-or-union-specifier declares new type, within translation unit.

types defined within translation unit, .c file in case.

there no problem defining 2 types same name in 2 different translation units.

however 2 types not compatible unless follow rules described in 6.2.7., p1. types defined not compatible.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -