What is the difference between these 2 ways of declaring a struct?
First way:
struct x {};
Second way:
struct _x {} x;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first defines only the type
struct x. The second defines the typestruct _xand defines a variable of that type namedx.Though it’s probably not what you had in mind, names starting with an underscore like
_xare reserved at file scope, so unless this is inside some other scope, the second has undefined behavior.