0

So I got myself g++ for windows following this.

Since I wanted to experiment with CImg I downloaded the beta from here.

I simply copied the cimg.h into g++'s include directory and also put some dependencies it couldn't find when compiling there.

However now when I try to compile something that uses cimg like this tutorial.

It gives me the error:

\Cimg.h:14485: macro 'log2' used without args

and the same for line 14492.

These lines look like so:

CImg<T>& log2() {
  cimg_for(*this,ptrd,T) *ptrd = (T)cimg::log2((double)*ptrd);
  return *this;
}

//! Compute the base-10 logarithm of each pixel value \newinstance.
CImg<Tfloat> get_log2() const {
  return CImg<Tfloat>(*this,false).log2();
}

This is literally the first time I use C++, so obviously I am already confused by the concept of all the header files and such, so I might be doing something wrong there. Or I may aswell be making a silly beginner mistake.

Wingblade
  • 9,585
  • 10
  • 35
  • 48
  • Someone is doing a `#define log2(x) something` in a header included before this. It interferes with the functions defined here. Perhaps you shouldn't have put everything in the compiler's include directory? – Bo Persson Jan 20 '13 at 10:32
  • @BoPersson What other ways of putting it do I have? As I said this is the first time I am using C++ so I don't know so many ways of including header files. – Wingblade Jan 20 '13 at 10:34
  • It is common to put each library in its own directory, and point the compiler there with a `-I directory` option. I'm not sure if that's your problem here, but it *might* be. – Bo Persson Jan 20 '13 at 10:38
  • I removed all the header files I had put before from the include directory to a directory of their own and pointed the compiler to it using `-I directory` as you said, however I still get the same error. – Wingblade Jan 20 '13 at 10:48
  • Most likely, there's a "log2" in some headerfile that you are including [directly or indirectly]. You can either use `#undef log2` or, my suggestion, name your log2 function something different. – Mats Petersson Jan 20 '13 at 15:46
  • Well it's not my log2 function but Cimg's, so I don't think I can name it otherwise. I guess I'll go try undef. – Wingblade Jan 20 '13 at 16:02

1 Answers1

0

As there is one header included before CImg.h that apparently does a

#define log2 something

you may try to change the order of the includes, so that this header does the #define after the #include "CImg.h". Looks like the error does not come from CImg though.

bvalabas
  • 241
  • 1
  • 1