error C2065: 'Quantum': undeclared identifier

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Zeranoe
Posts: 5
Joined: 2017-08-06T14:19:21-07:00
Authentication code: 1151

error C2065: 'Quantum': undeclared identifier

Post by Zeranoe »

When compiling this:

Code: Select all

#include <iostream>
#include "Magick++.h"

int main()
{
  std::cout << QuantumRange << std::endl;
}
I get:

Code: Select all

error C2065: 'Quantum': undeclared identifier
This appears to be a namespace issue. I thought it might be in the MagickCore namespace, but that didn't work either.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: error C2065: 'Quantum': undeclared identifier

Post by snibgo »

Your program compiles, builds and runs successfully for me. (Gnu C, Cygwin, Windows 8.1.)

I know almost nothing about build environments. For those that do, it might help if you said what version IM, on what platform, using what toolchain.
snibgo's IM pages: im.snibgo.com
Zeranoe
Posts: 5
Joined: 2017-08-06T14:19:21-07:00
Authentication code: 1151

Re: error C2065: 'Quantum': undeclared identifier

Post by Zeranoe »

I'm using MSVC 2017 and compiled with:

Code: Select all

cl "/IC:\Program Files\ImageMagick-7.0.6-Q16\include" bug.cc
The error is two lines:

Code: Select all

bug.cc(6): error C2065: 'Quantum': undeclared identifier
bug.cc(6): error C2059: syntax error: 'constant'
I can reproduce this same bug in Ubuntu 17.04 with:

Code: Select all

g++ -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu/ImageMagick-6 bug.cc

Code: Select all

In file included from /usr/include/ImageMagick-6/Magick++/Include.h:14:0,
                 from /usr/include/ImageMagick-6/Magick++.h:10,
                 from bug.cc:2:
/usr/include/ImageMagick-6/magick/magick-config.h:29:3: warning: #warning "you should set MAGICKCORE_QUANTUM_DEPTH to sensible default set it to configure time default" [-Wcpp]
 # warning "you should set MAGICKCORE_QUANTUM_DEPTH to sensible default set it to configure time default"
   ^~~~~~~
/usr/include/ImageMagick-6/magick/magick-config.h:30:3: warning: #warning "this is an obsolete behavior please fix your makefile" [-Wcpp]
 # warning "this is an obsolete behavior please fix your makefile"
   ^~~~~~~
/usr/include/ImageMagick-6/magick/magick-config.h:52:3: warning: #warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default" [-Wcpp]
 # warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"
   ^~~~~~~
/usr/include/ImageMagick-6/magick/magick-config.h:53:3: warning: #warning "this is an obsolete behavior please fix yours makefile" [-Wcpp]
 # warning "this is an obsolete behavior please fix yours makefile"
   ^~~~~~~
In file included from /usr/include/ImageMagick-6/magick/MagickCore.h:76:0,
                 from /usr/include/ImageMagick-6/Magick++/Include.h:42,
                 from /usr/include/ImageMagick-6/Magick++.h:10,
                 from bug.cc:2:
bug.cc: In function ‘int main()’:
/usr/include/ImageMagick-6/magick/magick-type.h:94:25: error: ‘Quantum’ was not declared in this scope
 #define QuantumRange  ((Quantum) 65535)
                         ^
bug.cc:6:16: note: in expansion of macro ‘QuantumRange’
   std::cout << QuantumRange << std::endl;
                ^~~~~~~~~~~~
/usr/include/ImageMagick-6/magick/magick-type.h:94:25: note: suggested alternatives:
 #define QuantumRange  ((Quantum) 65535)
                         ^
bug.cc:6:16: note: in expansion of macro ‘QuantumRange’
   std::cout << QuantumRange << std::endl;
                ^~~~~~~~~~~~
/usr/include/ImageMagick-6/magick/magick-type.h:93:24: note:   ‘MagickCore::Quantum’
 typedef unsigned short Quantum;
                        ^~~~~~~
/usr/include/ImageMagick-6/magick/magick-type.h:93:24: note:   ‘MagickCore::Quantum’
/usr/include/ImageMagick-6/magick/magick-type.h:94:34: error: expected ‘)’ before numeric constant
 #define QuantumRange  ((Quantum) 65535)
                                  ^
bug.cc:6:16: note: in expansion of macro ‘QuantumRange’
   std::cout << QuantumRange << std::endl;
                ^~~~~~~~~~~~
Post Reply