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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -