Quantcast
Viewing all articles
Browse latest Browse all 22040

How C handles the structures that are defined twice? [closed]

Structure rb_nvm_InitData_tst is defined in A.c with variables var1 and var2. It is initialized here with its instance rb_nvm_InitData_nvmast which is an array.

Structure rb_nvm_InitData_tst is also defined in B.h with variables Var1 and Var2 but it doesnt have any instance. Note that the variables start with Capital letters and C is case sensitive.

rb_nvm_InitData_nvmast is made extern in B.c and used in the file.

The problem is in B.c where the rb_nvm_InitData_nvmast[Index_u32].Var1 and rb_nvm_InitData_nvmast[Index_u32].Var2 are accessed. Note that I am accessing with Capital letters which are part of the structure in B.h.

As per my understanding, The instance rb_nvm_InitData_nvmast has variables var1 and var2. So, I shouldn't be allowed to access this data with variables Var1 Var2.

But the code works fine. No compiler error, no functional issue.

I wonder how it works. Can anyone provide me proper justification on how this is working?


Viewing all articles
Browse latest Browse all 22040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>