Replace C stdlib.h, stdint.h and math.h headers with C++ variants

This commit is contained in:
Gabriel Ferreira
2025-05-16 10:36:14 +02:00
parent b484b251c7
commit c0010702ce
43 changed files with 50 additions and 95 deletions

View File

@@ -6,13 +6,9 @@
#cmakedefine INT64X64_USE_128
#cmakedefine INT64X64_USE_DOUBLE
#cmakedefine INT64X64_USE_CAIRO
#cmakedefine01 HAVE_STDINT_H
#cmakedefine01 HAVE_INTTYPES_H
#cmakedefine HAVE_SYS_INT_TYPES_H
#cmakedefine01 HAVE_SYS_TYPES_H
#cmakedefine01 HAVE_SYS_STAT_H
#cmakedefine01 HAVE_DIRENT_H
#cmakedefine01 HAVE_STDLIB_H
#cmakedefine01 HAVE_GETENV
#cmakedefine01 HAVE_SIGNAL_H

View File

@@ -1074,7 +1074,7 @@ macro(process_options)
# Process core-config If INT128 is not found, fallback to CAIRO
if(${NS3_INT64X64} MATCHES "INT128")
check_cxx_source_compiles(
"#include <stdint.h>
"#include <cstdint>
int main()
{
if ((uint128_t *) 0) return 0;
@@ -1084,7 +1084,7 @@ macro(process_options)
HAVE_UINT128_T
)
check_cxx_source_compiles(
"#include <stdint.h>
"#include <cstdint>
int main()
{
if ((__uint128_t *) 0) return 0;
@@ -1129,12 +1129,9 @@ macro(process_options)
# Check for required headers and functions, set flags if they're found or warn
# if they're not found
check_include_file("stdint.h" "HAVE_STDINT_H")
check_include_file("inttypes.h" "HAVE_INTTYPES_H")
check_include_file("sys/types.h" "HAVE_SYS_TYPES_H")
check_include_file("sys/stat.h" "HAVE_SYS_STAT_H")
check_include_file("dirent.h" "HAVE_DIRENT_H")
check_include_file("stdlib.h" "HAVE_STDLIB_H")
check_include_file("signal.h" "HAVE_SIGNAL_H")
check_include_file("netpacket/packet.h" "HAVE_PACKETH")
check_function_exists("getenv" "HAVE_GETENV")
@@ -1287,13 +1284,13 @@ macro(process_options)
<limits>
<list>
<map>
<math.h>
<cmath>
<ostream>
<queue>
<set>
<sstream>
<stdint.h>
<stdlib.h>
<cstdint>
<cstdlib>
<string>
<tuple>
<typeinfo>

View File

@@ -20,7 +20,7 @@
#include "ns3/double.h"
#include "ns3/log.h"
#include <math.h>
#include <cmath>
/**
* @file

View File

@@ -13,7 +13,7 @@
#include "ns3/log.h"
#include "ns3/uinteger.h"
#include <math.h>
#include <cmath>
NS_LOG_COMPONENT_DEFINE("ThreeGppHttpVariables");

View File

@@ -51,45 +51,7 @@
// extern const char * cairo_impl64;
// extern const char * cairo_impl128;
/*for compatibility with MacOS and Cygwin*/
#ifndef HAVE_STDINT_H
#ifdef __APPLE__
#define HAVE_STDINT_H 1
#elif defined(WIN32)
#define HAVE_STDINT_H 1
#endif
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#elif HAVE_INTTYPES_H
# include <inttypes.h>
#elif HAVE_SYS_INT_TYPES_H
# include <sys/int_types.h>
#elif defined(_MSC_VER)
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
# ifndef HAVE_UINT64_T
# define HAVE_UINT64_T 1
# endif
# ifndef INT16_MIN
# define INT16_MIN (-32767-1)
# endif
# ifndef INT16_MAX
# define INT16_MAX (32767)
# endif
# ifndef UINT16_MAX
# define UINT16_MAX (65535)
# endif
#else
#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
#endif
#include <cstdint> // PDB
#ifdef __cplusplus
extern "C" {

View File

@@ -11,9 +11,9 @@
#include "string.h"
#include <cstdlib> // std::getenv
#include <cstdlib> // Global functions setenv, unsetenv
#include <cstring> // strlen
#include <iostream> // clog
#include <stdlib.h> // Global functions setenv, unsetenv
/**
* @file

View File

@@ -22,7 +22,7 @@
#include "log.h"
#include <stdlib.h>
#include <cstdlib>
#include <sys/types.h>
/**
@@ -347,7 +347,7 @@ enum fnv_type {
* Share and Enjoy! :-)
*/
//#include <stdlib.h> //PDB
//#include <cstdlib> //PDB
//#include "fnv.h" //PDB
@@ -495,7 +495,7 @@ fnv_32a_str(char *str, Fnv32_t hval)
* Share and Enjoy! :-)
*/
//#include <stdlib.h> //PDB
//#include <cstdlib> //PDB
//#include "fnv.h" //PDB

View File

@@ -9,11 +9,11 @@
#include "assert.h"
#include "log.h"
#include <cstdint>
#include <iomanip> // showpos
#include <iostream>
#include <limits>
#include <sstream>
#include <stdint.h>
/**
* @file

View File

@@ -9,6 +9,7 @@
#include "encode-decode.h"
#include <arpa/inet.h>
#include <cstdlib>
#include <cstring>
#include <errno.h>
#include <iomanip>
@@ -17,7 +18,6 @@
#include <net/if.h>
#include <netinet/in.h>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <sys/ioctl.h>
#include <sys/socket.h>

View File

@@ -19,6 +19,7 @@
#include "ns3/trace-helper.h"
#include <arpa/inet.h>
#include <cstdlib>
#include <errno.h>
#include <iomanip>
#include <iostream>
@@ -28,7 +29,6 @@
#include <net/if.h>
#include <netinet/in.h>
#include <netpacket/packet.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sys/ioctl.h>

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: GPL-2.0-only
*/
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdint.h>
#include <string>
namespace ns3

View File

@@ -7,6 +7,7 @@
#include "creator-utils.h"
#include <arpa/inet.h>
#include <cstdlib>
#include <errno.h>
#include <iomanip>
#include <iostream>
@@ -15,7 +16,6 @@
#include <netinet/in.h>
#include <netpacket/packet.h>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <sys/ioctl.h>
#include <sys/socket.h>

View File

@@ -9,6 +9,8 @@
#include "ns3/mac48-address.h"
#include <arpa/inet.h>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <errno.h>
#include <fcntl.h>
@@ -19,8 +21,6 @@
#include <net/route.h>
#include <netinet/in.h>
#include <sstream>
#include <stdint.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>

View File

@@ -19,6 +19,7 @@
#include "ns3/trace-helper.h"
#include <arpa/inet.h>
#include <cstdlib>
#include <errno.h>
#include <iomanip>
#include <iostream>
@@ -28,7 +29,6 @@
#include <net/if.h>
#include <netinet/in.h>
#include <netpacket/packet.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sys/ioctl.h>

View File

@@ -15,8 +15,8 @@
#include "ns3/pcap-file-wrapper.h"
#include "ns3/ptr.h"
#include <cstdint>
#include <fstream>
#include <stdint.h>
#include <string>
namespace ns3

View File

@@ -11,7 +11,7 @@
#include "ns3/ipv4-address.h"
#include "ns3/log.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -10,7 +10,7 @@
#include "ns3/ipv6-address.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -14,8 +14,8 @@
#include "ns3/buffer.h"
#include "ns3/log.h"
#include <cstdint>
#include <iostream>
#include <stdint.h>
namespace ns3
{

View File

@@ -52,7 +52,7 @@
#include "ns3/uinteger.h"
#include <algorithm>
#include <math.h>
#include <cmath>
namespace
{

View File

@@ -23,9 +23,9 @@
#include "ns3/pointer.h"
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <list>
#include <stdint.h>
#include <stdlib.h>
#include <vector>
namespace ns3

View File

@@ -9,7 +9,7 @@
#include "ns3/angles.h"
#include <math.h>
#include <cmath>
/**
* @file

View File

@@ -15,8 +15,8 @@
#include "ns3/pcap-file-wrapper.h"
#include "ns3/ptr.h"
#include <cstdint>
#include <fstream>
#include <stdint.h>
#include <string>
namespace ns3

View File

@@ -13,7 +13,7 @@
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction.
*/
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -11,8 +11,8 @@
#include "ns3/log.h"
#include "ns3/packet.h"
#include <cstdint>
#include <list>
#include <stdint.h>
namespace ns3
{

View File

@@ -9,6 +9,7 @@
#include "ns3/mac48-address.h"
#include <cerrno>
#include <cstdint>
#include <cstdlib>
#include <cstring> // for strerror
#include <fcntl.h>
@@ -19,7 +20,6 @@
#include <net/route.h>
#include <netinet/in.h>
#include <sstream>
#include <stdint.h>
#include <string>
#include <sys/ioctl.h>
#include <sys/socket.h>

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: GPL-2.0-only
*/
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdint.h>
#include <string>
namespace ns3

View File

@@ -21,7 +21,7 @@
#include "ns3/packet.h"
#include "ns3/simulator.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -26,7 +26,7 @@
#include "ns3/pointer.h"
#include "ns3/simulator.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -16,7 +16,7 @@
#include "ns3/log.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -12,7 +12,7 @@
#include "ns3/uinteger.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -6,7 +6,7 @@
* Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
* <amine.ismail@udcast.com>
*/
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -12,7 +12,7 @@
#include "ns3/address-utils.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -11,7 +11,7 @@
#include "ns3/ipv4-address.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -20,7 +20,7 @@
#include "ns3/udp-header.h"
#include "ns3/udp-l4-protocol.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -10,7 +10,7 @@
#include "ns3/address-utils.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -29,7 +29,7 @@
#include "ns3/pointer.h"
#include "ns3/simulator.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -20,7 +20,7 @@
#include "ns3/pointer.h"
#include "ns3/simulator.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -14,7 +14,7 @@
#include "ns3/log.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -11,7 +11,7 @@
#include "service-flow.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -27,7 +27,7 @@
#include "ns3/pointer.h"
#include "ns3/simulator.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -9,7 +9,7 @@
#include "ul-job.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -10,7 +10,7 @@
#include "ul-mac-messages.h"
#include <stdint.h>
#include <cstdint>
namespace ns3
{

View File

@@ -16,10 +16,10 @@
#include "ns3/system-wall-clock-ms.h"
#include <algorithm>
#include <cstdlib> // for exit ()
#include <iostream>
#include <limits>
#include <sstream>
#include <stdlib.h> // for exit ()
#include <string>
using namespace ns3;