adtools icon indicating copy to clipboard operation
adtools copied to clipboard

log2 problems

Open afxgroup opened this issue 5 years ago • 4 comments

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?

afxgroup avatar Jan 07 '20 17:01 afxgroup

Try transforming the macro into an inline.

AV00 avatar Jan 08 '20 14:01 AV00

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

kas1e avatar Jan 17 '20 08:01 kas1e

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

afxgroup avatar Jan 17 '20 11:01 afxgroup

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.

kas1e avatar Feb 02 '21 06:02 kas1e