sba1 / adtools

Experimental GNU toolchain for AmigaOS
31 stars 18 forks source link

log2 problems #79

Open afxgroup opened 4 years ago

afxgroup commented 4 years ago

i've noticed that log2 with newlib as an issue.

If you try this simple program

#include <cmath>
#include <iostream>

int main() {
        std::cout << std::log2(10) << std::endl;
        return 0;
}

And try to compile it you will have this error:

In file included from /usr/ppc-amigaos/include/c++/8.3.0/cmath:45,
                 from log2.c:1:
log2.c: In function 'int main()':
log2.c:5:20: error: expected unqualified-id before '(' token
  std::cout << std::log2(10) << std::endl;
                    ^~~~

This because log2 into newlib (in math.h) that is called from cmath:45 is defined as a macro so std::seems not work

#define log2(x) (log (x) / M_LOG2_E)

Do you have a quick workaround for this?

AV00 commented 4 years ago

Try transforming the macro into an inline.

kas1e commented 4 years ago

Is anyone was able to deal with ? I currently hit the same issue.

afxgroup commented 4 years ago

The fastest solution i've found is to add using namespace std; and then remove std:: and it works

kas1e commented 3 years ago

from newlib's side everything about "not a member of std::" was fixed in the new beta of newlib 53.69 and adtools recompiled with new newlib's headers.