Preprocessor defined in window.h

Bug #1407994 reported by Maxime Lavigne
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Brewtarget
Fix Committed
Medium
Mik Firestone

Bug Description

Environment: Windows 7 x86_64, vs2010, vs2012.

Steps to reproduce.
  1 - Compile project.

Results
  Compiler generate errors for unit.h:89

Compiler errors:
  2>e:\brewtarget\src\src\unit.h(90): error C2062: type 'char' unexpected
  2>e:\brewtarget\src\src\unit.h(90): error C3805: 'type': unexpected token, expected either '}' or a ','

unit.h:
  enum unitScale
  {
     noScale = -1,
     extrasmall = 0,
     small = 1, // <- Here
     medium = 2,
     large = 3,
     extralarge = 4,
     huge = 5,
     without=1000
  };

Issues
  After being confused to no end and embarking on a journey of debugging, helped by Stack Overflow http://stackoverflow.com/questions/27793470/why-does-smallgive-an-error-about-char/27794577#27794577.
  windows.h in one of its import defines #define small char, and therefore this enum fails for syntax reason.

Possible Fix
  I propose slightly altering the name of the variable if you want to build on windows or add #undef small in every file possibly using it.

Revision history for this message
Mik Firestone (mikfire) wrote :

That value is used all through the UnitSystems and possibly into Units. Renaming isn't trivial. but that's the best option. Let me give this some thought.

Changed in brewtarget:
assignee: nobody → Mik Firestone (mikfire)
importance: Undecided → Medium
milestone: none → 2.2.0
Revision history for this message
gigatropolis (gigatropolis) wrote : Re: [Bug 1407994] [NEW] Preprocessor defined in window.h

I fixed this bug and it is in merge request #104 in "reviewing" state. I had the same pain you did
  Change made in unit.h
#ifdef small#undef small#endif

     On Tuesday, January 6, 2015 7:15 AM, Maxime Lavigne <email address hidden> wrote:

 Public bug reported:

Environment: Windows 7 x86_64, vs2010, vs2012.

Steps to reproduce.
  1 - Compile project.

Results
  Compiler generate errors for unit.h:89

Compiler errors:
  2>e:\brewtarget\src\src\unit.h(90): error C2062: type 'char' unexpected
  2>e:\brewtarget\src\src\unit.h(90): error C3805: 'type': unexpected token, expected either '}' or a ','

unit.h:
  enum unitScale
  {
    noScale = -1,
    extrasmall = 0,
    small = 1,  // <- Here
    medium = 2,
    large = 3,
    extralarge = 4,
    huge = 5,
    without=1000
  };

Issues
  After being confused to no end and embarking on a journey of debugging, helped by Stack Overflow http://stackoverflow.com/questions/27793470/why-does-smallgive-an-error-about-char/27794577#27794577.
  windows.h in one of its import defines #define small char, and therefore this enum fails for syntax reason.

Possible Fix
  I propose slightly altering the name of the variable if you want to build on windows or add #undef small in every file possibly using it.

** Affects: brewtarget
    Importance: Undecided
        Status: New

--
You received this bug notification because you are a member of
brewtarget-devs, which is subscribed to Brewtarget.
Matching subscriptions: Bug Mail
https://bugs.launchpad.net/bugs/1407994

Title:
  Preprocessor defined in window.h

Status in Brewtarget:
  New

Bug description:
  Environment: Windows 7 x86_64, vs2010, vs2012.

  Steps to reproduce.
    1 - Compile project.

  Results
    Compiler generate errors for unit.h:89

  Compiler errors:
    2>e:\brewtarget\src\src\unit.h(90): error C2062: type 'char' unexpected
    2>e:\brewtarget\src\src\unit.h(90): error C3805: 'type': unexpected token, expected either '}' or a ','

  unit.h:
    enum unitScale
    {
      noScale = -1,
      extrasmall = 0,
      small = 1,  // <- Here
      medium = 2,
      large = 3,
      extralarge = 4,
      huge = 5,
      without=1000
    };

  Issues
    After being confused to no end and embarking on a journey of debugging, helped by Stack Overflow http://stackoverflow.com/questions/27793470/why-does-smallgive-an-error-about-char/27794577#27794577.
    windows.h in one of its import defines #define small char, and therefore this enum fails for syntax reason.

  Possible Fix
    I propose slightly altering the name of the variable if you want to build on windows or add #undef small in every file possibly using it.

To manage notifications about this bug go to:
https://bugs.launchpad.net/brewtarget/+bug/1407994/+subscriptions

Revision history for this message
Philip (rocketman768) wrote :

Mik,

I usually fix these by prepending the name of the enum to each item, for example 'unitScale_small'. I would prefer it be fixed this way.

Giga,

Since Mik is planning to fix this in a separate MR, push a new version of your MR104 without the #undef stuff to avoid conflict.

Revision history for this message
Mik Firestone (mikfire) wrote :

Would you accept a prefix of "bt_"?

After some trial and error, I had realized that without a prefix there would be no possible way of avoiding a name collision. But prefixing with "unitScale_" is a lot of typing, and I am not a good typist :) If you really prefer "unitScale_", no problem. But I thought I would ask first.

Revision history for this message
Mik Firestone (mikfire) wrote :

Fixed with merge request 114

Changed in brewtarget:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.