3

I'm trying to compile a library in C++ as dll windows with visual studio 2017.

I have all C++/H compiled with clang 3.8 for android and it works.

I created a new project as dynamic library with LLVM as platform toolset. Now I'm trying to build but there is an error :

Error C2065 'M_PI': undeclared identifier

This error is present in many .cpp files. All linked .h contains :

#include <cmath>

I replaced by :

#define _USE_MATH_DEFINES // for C++  
#include <cmath>

But it change nothing. What can I do ?

A.Pissicat
  • 3,023
  • 4
  • 38
  • 93
  • 1
    [Possibly replicated](https://stackoverflow.com/questions/6563810/m-pi-works-with-math-h-but-not-with-cmath-in-visual-studio) – felix Nov 20 '18 at 15:01
  • Also see [Best platform independent pi constant?](https://stackoverflow.com/q/21867617/1708801) – Shafik Yaghmour Nov 21 '18 at 02:38

1 Answers1

8

This is a known issue, try defining _USE_MATH_DEFINES as a definition in your project properties instead of the file itself.

This can be found in project properties -> C/C++ -> Preprocessor -> Preprocessor definitions.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122