VC++Tips

源代码在linux下写的,先要在windows下编译,用到这几个函数,网上搜到替换(drand48()->((double)rand()/(RAND_MAX+1.0)), srand48->srand, lrand48->rand)


Visual C++ 2008 Standard:M_PI is not defined

In my app I use the constant M_PI.
As recommended, in my cpp file I wrote:

#define _USE_MATH_DEFINES
#include <cmath> 

The compiler complains: "error C2065: 'M_PI' : undeclared identifier"

I have transferred the solution and source files from the Visual Studio 2005 Standard. In this version of VS all was compiled and linked just fine.

Replacing the <cmath> with <math.h>

#define _USE_MATH_DEFINES
#include <math.h>

solves the problem: all compiles OK.

Also if I define _USE_MATH_DEFINES in ProjectProperties/C++/Prepocessor
and #include <cmath> in the cpp module, all works.


VS 2010: How to change VC++ directories Inherited values (read only)

VS2010 introduces the user settings file (Microsoft.cpp.<Platform>.users.props) to control global settings including Global search path. These files are located at $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory.

The issue you are seeing is a bug in the UI. To make it possible to change the ordering of these read-only directories, here is the workaround that you can apply:

1. open up the property manager, 
2. right click on the .user.props file to bring up the property page
3. open up VC++ Directories -> Include Directories, add new paths after $(IncludePath)
4. Click on the "Edit" dropdown on VC++ Directories -> Include Directories property, the user directories as well as the inherited values will show up in the upper pane
5. you can move the directory orders as you wish and save. 

posted on 2012-11-26 10:54  -小草-  阅读(248)  评论(0编辑  收藏  举报

导航