目前,我正在使用由两家汇编者编成的代码<代码>popen功能:MS视觉演播室和gcc(按纬度)。 稍后,我不妨加上“cc”。
The function is called popen
for gcc, but _popen
for MSVS, so i added the following to my source code:
#ifdef _MSC_VER
#define popen _popen
#define pclose _pclose
#endif
这样做,但我想理解是否存在这些问题的标准解决办法(即回顾与<条码>条码/代码>/<条码>的类似情况。 具体来说,我想理解以下几点:
- Is
_MSC_VER
the right flag to depend on? I chose it because i have the impression that linux environment is "more standard". - If i put these
#define
s in some header file, is it important whether i#include
it before or afterstdio.h
(for the case ofpopen
)? - If
_popen
is defined as a macro itself, is there a chance my#define
will fail? Should i use a "new" token likemy_popen
instead, for that reason or another? - Did someone already do this job for me and made a good "portability header" file that i can use?
- Anything else i should be aware of?