|
From: Fabian on 16 Apr 2008 09:37 Hello, I will have to build my application with a different compiler at some point. The secure functions like sprintf_s are a nice feature of the visual c++ compiler. But they will probably not be supported on the target platform. If I had the possibility to #define a macro which uses sprintf_s if the visual c++ compiler is used and uses the standard sprintf if a different compiler is used I would not have to switch off the deprecated warnings. Can I define a macro with optional arguments as sprintf resp. sprintf_s use? Thanks for your suggestions, Fabian
From: Alex Blekhman on 16 Apr 2008 10:44 "Fabian" wrote: > Can I define a macro with optional arguments as sprintf resp. > sprintf_s use? Yes, VC++ supports variadic macros: "Variadic Macros" http://msdn2.microsoft.com/en-us/library/ms177415.aspx Alex
From: adebaene on 16 Apr 2008 11:50 On 16 avr, 15:37, Fabian <Fab...(a)discussions.microsoft.com> wrote: > Hello, > > I will have to build my application with a different compiler at some point. > The secure functions like sprintf_s are a nice feature of the visual c++ > compiler. But they will probably not be supported on the target platform. If > I had the possibility to #define a macro which uses sprintf_s if the visual > c++ compiler is used and uses the standard sprintf if a different compiler is > used I would not have to switch off the deprecated warnings. > Can I define a macro with optional arguments as sprintf resp. sprintf_s use? Depending on your exact situation, you should do it another way : Write your code using printf, and when compiling with Visual C++ #define, _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES = 1 See http://msdn2.microsoft.com/en-us/library/ms175759(VS.80).aspx Arnaud
From: Fabian on 16 Apr 2008 15:02 Hello Arnaud, > and when compiling with Visual C++ > #define, _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES = 1 How can I find out automatically whether I am compiling with Visual C++? If I try it with #ifdef _MSVC_ Visual Studio tells me (by greying out the following code) that _MSVC_ is not defined. Thanks, Fabian
From: Igor Tandetnik on 16 Apr 2008 15:13 Fabian <Fabian(a)discussions.microsoft.com> wrote: > How can I find out automatically whether I am compiling with Visual > C++? _MSC_VER -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
|
Next
|
Last
Pages: 1 2 3 Prev: Prologue/Epilogue for SEH Next: sizeof() struct w/ nested enum returns wrong size |