How to determine what folder is the SAS macro stored in - sas

I have a program (it was developed by my colleagues) with 20 paths in SASAUTOS. So, when I see calling of some macro in the code I can't easily determine what folder the macro is stored in. Is there some function for this purpose or system table with names and physical paths to macroes which can be used in current SAS session?

There are two system options that can help when you run the code.
MAUTOCOMPLOC will display the autocall macro source location in the SAS log when the autocall macro is compiled.
MAUTOLOCDISPLAY will display the autocall macro source location in the log when the macro is run.
388 options mautolocdisplay mautocomploc;
389 %let x=%left(x);
MAUTOCOMPLOC: The autocall macro LEFT is compiling using the autocall source file C:\Program
Files\SASHome\SASFoundation\9.4\core\sasmacro\left.sas.
MAUTOLOCDISPLAY(LEFT): This macro was compiled from the autocall file C:\Program
Files\SASHome\SASFoundation\9.4\core\sasmacro\left.sas
MAUTOCOMPLOC: The autocall macro VERIFY is compiling using the autocall source file C:\Program
Files\SASHome\SASFoundation\9.4\core\sasmacro\verify.sas.
MAUTOLOCDISPLAY(VERIFY): This macro was compiled from the autocall file C:\Program
Files\SASHome\SASFoundation\9.4\core\sasmacro\verify.sas
390 %let x=%left(x);
MAUTOLOCDISPLAY(LEFT): This macro was compiled from the autocall file C:\Program
Files\SASHome\SASFoundation\9.4\core\sasmacro\left.sas
MAUTOLOCDISPLAY(VERIFY): This macro was compiled from the autocall file C:\Program
Files\SASHome\SASFoundation\9.4\core\sasmacro\verify.sas
If you just want to figure out where a particular file is then you can try asking SAS to find it for you. Make an aggregate fileref that points to the same folders as your SASAUTOS settings.
filename xx ('path1' 'path2' 'path3') ;
Then use a simple INFILE statement to find the path of a particular file.
data _null_;
length fname $500;
infile xx('mymacro.sas') filename=fname;
input;
put fname= ;
stop;
run;

Related

Handling preprocessor macro in a single header file?

In my c++ project, I have some preprocessor macro commands.As an example:
#define ENABLE_PHOTO_SENSOR //will be put in three source file (.cc file)
#define SAVE_ROOT_FILE //will be placed 6 source file
...
Should I have to put all these macro commands in a single header file? If I do like this, when I change one of the macro commands(example undef one macro) and compile the program again, all the source files including those header files are compiled again. If I use separate header file for each macro command, only related source file compiled. But what I want is to control all the macro commands from a single file and when I change a macro command, only the files related to that macro commands are changed.
Finally, I am using cmake to generate make files. Is it possible to change these macro commands in the build directory?If it is how?

compile a cpp file with multiple different header files

I have a single cpp file and multiple hpp files. For each hpp file, I want to create an executable using the same cpp file. The header files have different names. Can I do this in CMake?
So I have
source_1.cpp
header_1.hpp
header_2.hpp
...
and I want to create
executable_1
executable_2
...
The C++ preprocessor can use macros for #include.
That is, you can have something like:
#include HEADER_FILE_TO_INCLUDE
Then when building the source file you could define the macro on the command-line:
g++ -DHEADER_FILE_TO_INCLUDE="\"header_1.hpp\"" source_1.cpp
To do this with CMake you first of all need multiple executable targets, where you specify the same source file for each target.
Then you can use target_compile_definitions to specify the macro and the header file to use.
Something like
add_executable(executable_1 source_1.cpp)
target_compile_definitions(executable_1 HEADER_FILE_TO_INCLUDE="header_1.hpp")
add_executable(executable_2 source_1.cpp)
target_compile_definitions(executable_2 HEADER_FILE_TO_INCLUDE="header_2.hpp")
If all header files are named header_X.hpp, with X just being a sequence number, then you could easily create a loop from 1 to the max value of header file numbers.

how to use macro definitions that are defined in a headerfile(.h) file in a makefile in linux

I have written certain macros in a headerfile(.h)file. I want those macros to be used in a makefile in linux OS. How can i declare (or) get that macro definitions from a header file in to a makefile.
I have added the file using "-include" in a makefile, but i could not read the macro definitions.
You can't. Header files are for C code.

VC post-build event command

Now I am building a .dll project with VC 10. Depending on whether certain libraries are included or not, the output .dll as well as its corresponding lib file names should be different. For example, if the project uses the native STL library provided by Mirosoft, the .dll name is *_native_stl.dll; if the project uses STLport, then the output .dll name is *_stlport.dll. Of course I can do it manually, but I am now considering to let VC 10 do it for me automatically. My plan is that if I use a certain library, I define a variable to represent it in the Preprocessor Definitions (located in C/C++ Preprocessor)section. After that, I define a .bat file in the Post-Build Event (located in Build Events) section: call "$(ProjectDir)\script.bat". In the script.bat file, I will changed the default .dll output name $(OutDir)$(TargetName)$(TargetExt) according to the variable definition in the Preprocessor Definitions section. My main problem is that for in batch file how I can check a certain variable is defined or not. Thanks! Any suggestions on changing output file name are welcome as well.
My main problem is that for in batch file how I can check a certain variable is defined or not. Thanks!
You can check this with a statement like this:
if "%MYVAR%" == "" set undefined=1
The variable undefined will be set to 1 only if MYVAR is not defined.

Compiling a project (VS 2008) with the /p argument (preprocess to a file) doesn't compile

I have a project in C++ that I would like to view the preprocessor output to see what some #defines and macros would look like. I tried the /p switch to turn on the preprocess to a file option to the compiler (it turns off full compilation and only runs the preprocessor) but my project now refuses to compile and shows a long list of errors starting with:
"Cannot open include file: 'stdafx.h': No such file or directory".
The project compiles fine without the /p argument, of course. Any suggestions?
If you run cl.exe on its own then you would need to supply all the same parameters as the IDE does when building, otherwise it can't find all the include paths and preprocessor macros. However, there is another way to do this. In the project file, select the .cpp file you want, and choose Properties > C++ > Preprocessor > Generate preprocessor file. Then compile the .cpp file.
This will generate the preprocessed file (file.i I think) in the output directory. It's a shame there isn't an easier way of just selecting a file and hitting 'preprocess' but this could probably be done quite easily with a VisualStudio macro. Don't forget to set the option back afterwards.
Are all the other options (like /I) still the same when you compile with /p? It sounds like it's not picking up your header files. Alternately because it's trying to pre-process all the includes it's no longer generating the stdafx.h precompiled header - you could try just including all the needed headers directly instead of that.