Tuesday, May 24, 2005

見鬼的 vc…

在 VC.NET 2004 的 math.h 裡提到 要使用 M_PI 這些常數的話要先定義 _USE_MATH_DEFINES

/* Define _USE_MATH_DEFINES before including math.h to expose these macro * definitions for common math constants. These are placed under an #ifdef * since these commonly-defined names are not part of the C/C++ standards. */


#define _USE_MATH_DEFINES #include <math.h>


e:\prog\Research\test.cpp(310): error C2065: 'M_PI' :       未宣告的識別項 e:\prog\Research\test.cpp(312): error C3861: 'M_PI':       找不到識別項,即使是使用與引數相關的查閱也一樣

見鬼的是 debug build 是正常的,換到 release build 就爛了 只好自己再定義一個

#ifndef M_PI # define M_PI          3.14159265358979323846 #endif

不過 release build 還真的會快一點@@ 大概 vc 的 debug build 開了太多 runt-time check feature 吧

This article was originally posted on this site.

1 comment: