cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmnStrings.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Anton Deguet
7  Created on: 2009-11-08
8 
9  (C) Copyright 2009 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 
27 #pragma once
28 
29 #ifndef _cmnStrings_h
30 #define _cmnStrings_h
31 
33 
34 #include <stdarg.h>
35 #include <stdio.h>
36 
40 inline int cmn_snprintf(char * destination, size_t size, const char * format, ...) {
41  va_list arguments;
42  va_start(arguments, format);
43  int result;
44 #if (CISST_COMPILER == CISST_DOTNET2003)
45  result = _vsnprintf(destination, size, format, arguments);
46 #elif (CISST_COMPILER == CISST_DOTNET2005) || (CISST_COMPILER == CISST_DOTNET2008)
47  result = vsnprintf_s(destination, size, _TRUNCATE, format, arguments);
48 #else
49  result = vsnprintf(destination, size, format, arguments);
50 #endif
51  va_end(arguments);
52  return result;
53 }
54 
55 #endif // _cmnStrings_h
Portability across compilers and operating systems tools.
int cmn_snprintf(char *destination, size_t size, const char *format,...)
Definition: cmnStrings.h:40