Version: SMASH-3.1
deprecate_c_functions.h File Reference

This file should only be included to find deprecated calls to the C library. More...

#include <cctype>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include "forwarddeclarations.h"
#include "macros.h"

Go to the source code of this file.

Namespaces

 smash
 

Macros

#define SMASH_DEPRECATE_NONSTD(fun__)
 This macro is used to define functions that are in the C library and in the std namespace. More...
 

Detailed Description

This file should only be included to find deprecated calls to the C library.

It should not be included in default builds since it slows down compilation.

Definition in file deprecate_c_functions.h.

Macro Definition Documentation

◆ SMASH_DEPRECATE_NONSTD

#define SMASH_DEPRECATE_NONSTD (   fun__)
Value:
template <typename... Ts> \
SMASH_DEPRECATED("Please add the std:: namespace for this function.") \
auto fun__(Ts&&... args)->decltype(std::fun__(args...)) { \
return std::fun__(args...); \
}

This macro is used to define functions that are in the C library and in the std namespace.

If a call to such a function without explicit namespace qualification is made it will then call the function from the smash namespace. Since the functions here are marked as deprecated they issue a warning if some code tries to use a C library function call.

Rationale: Functions in the C library are not overloaded for different data types. Thus a call to e.g. x = abs(x) with float x is a call to x = static_cast<float>(abs(static_cast<double>(x))). These casts are executed implicitly and therefore not noticed if the cast was unintentional.

And then, of course, this is C++ code. The ability to call C functions exists in C++ because C headers should compile in C++. The only correct way to write C++ code is to use the C++ interface. This may enable additional optimization opportunities.

Definition at line 53 of file deprecate_c_functions.h.