Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does "small" give an error about "char"?

Trying to compile an open source project with both VS2010, VS2012 in x86 and x86_64 on a windows platform running QT5.4.

A file named unit.h contains a part :

[...]
// DO NOT change noscale's value. Lots of assumptions are made based on this
// value, both in the code and (more importantly) in the database.
enum unitScale
{
   noScale = -1,
   extrasmall = 0,
   small = 1, // Line that causes errors.
   medium = 2,
   large = 3,
   extralarge = 4,
   huge = 5,
   without = 1000
};
[...]

Generates

  • error C2062: type 'char' unexpected
  • error C3805: 'type': unexpected token, expected either '}' or a ','

I tried every trick in my hat to solve it. I removed every use of the "small" enum in the code and I still get the error. But after having removed all the uses, I rename "small" to "smallo" everything is fine. It seems to indicate name collision but a file search gives me no references in the whole project. It's not any keyword I know of.

Got any ideas?

EDIT: Thanks to very helpful comments here is an even stranger version that works. Could somebody explain?

#ifdef small // Same with just straight "#if"
#pragma message("yes")
#endif
#ifndef small
#pragma message("no") // Always prints no.
#endif

#undef small
enum unitScale
{
   noScale = -1,
   extrasmall = 0,
   small = 1,
   medium = 2,
   large = 3,
   extralarge = 4,
   huge = 5,
   without = 1000
};

EDIT 2: The pragma directive was showing yes but only in files that had previously loaded the windows.h header, and it was lost in the compiler output in a sea of no. Thanks everyone! What a quest.

like image 893
malavv Avatar asked Feb 12 '23 05:02

malavv


1 Answers

small is a defined in rpcndr.h. It is used as datatype for MIDL.

like image 96
harper Avatar answered Feb 22 '23 07:02

harper