0
struct __Garbage__MyStruct
{};

What is the purpose of this in c++? It always occurs after the declaration.

struct MyStruct;
iammilind
  • 68,093
  • 33
  • 169
  • 336

2 Answers2

4

No, it's not a keyword. Whatever code you are using is just defining a struct called __Garbage__MyStruct for some purpose that I can't make out from just the code you have here.

That said, it is not a good idea to use names in C++ that contain two adjacent underscores.

These names are reserved by the implementation for whatever use they'd like (for example, their own internal macros and globals), so this results in undefined behavior. I'd strongly avoid code like this if at all possible.

Hope this helps!

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
  • 1
    "begin with" => "contain" Any names with two consecutive underscores are reserved. – James McNellis Feb 01 '12 at 05:59
  • 1
    I would add that just removing an underscore would not fix the problems, since identifiers beginning with a single underscore and a capital letter are also reserved to the compiler. – Joel Feb 01 '12 at 06:01
  • That's interesting, @James, in C it's only reserved if it begins with underscore-capital or underscore-underscore. I wonder why C++ imposed the extra rule of "containing double underscore". – paxdiablo Feb 01 '12 at 06:16
  • @paxdiablo- Perhaps so as not to conflict with changes in C if the languages diverged? – templatetypedef Feb 01 '12 at 06:25
  • @paxdiablo I do not know. An answer to another question has [the complete list of reserved underscored names](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier). – James McNellis Feb 01 '12 at 06:40
0

No, _Garbage_MyStruck is not a reserved work in the C++ languages so this must be something someone defined in their software has a meaning there.

Damian
  • 4,395
  • 4
  • 39
  • 67