VisualStudio
사용자 정의 매크로 변수 추가하기
Mesia
2016. 7. 20. 09:07
[참조] https://sites.google.com/site/pinyotae/Home/visual-studio-visual-c/create-user-defined-environment-variables-macros
Create user-defined environment variables (macros)
User-define environment variables or user-defined macros are important in Visual C++ when we want to share certain properties across projects in a solution or even across solutions. For example, a library set, such as ITK, may consist of multiple libraries. If many projects in a solution need to use them, we may need to repetitively specify include paths and libraries to these projects. This is error prone and time consuming. Moreover, if we want to upgrade the library or just change the library folder, without using a user-defined environment variable, we will need to repeat the whole things. If we create a macro, such as ITK_INC, that specifies include paths to ITK library headers, we then can just refer to $(ITK_INC) in the include directory. Any change to the variable will be adopted by referring projects automatically. Consequently, the projects will be more organized and ready for changes. So, how to create such a macro? First of all, we need a new property sheet, which can be created as described in MSDN. This is illustrated by Figure 1. To make the solution even more organized, I suggest create a new project to specifically host this new property sheet. Why? Because when we have many projects and need to locate this property sheet, we will have a hard time locate the property sheet if we create it in any random project. Thus, creating a solution project called 'SolutionSettings' is recommended. Figure 1 Call up Property Manager to create a new property sheet. Associate the property sheet with a specialized project in a solution is highly recommended. Next, we are ready to create a user-defined macro.
Special Thanks: I first got an understanding of environment variable from a post at StackOverflow. The answer in the post, however, used a text-based approach to create and handle property values. But I'm new to this stuff and prefer to use a GUI. once I could get it done, I wrote this page and hope other people can make use of it. Pinyo Taeprasartsit June 12, 2010 |