Merge pull request #626 from sergiud/use-c++-headers

use C++ headers
This commit is contained in:
Sergiu Deitsch 2021-03-31 09:42:48 +02:00 committed by GitHub
commit 5abed00e3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 75 additions and 86 deletions

View File

@ -97,8 +97,6 @@ check_include_file_cxx (inttypes.h HAVE_INTTYPES_H)
check_include_file_cxx (memory.h HAVE_MEMORY_H) check_include_file_cxx (memory.h HAVE_MEMORY_H)
check_include_file_cxx (pwd.h HAVE_PWD_H) check_include_file_cxx (pwd.h HAVE_PWD_H)
check_include_file_cxx (stdint.h HAVE_STDINT_H) check_include_file_cxx (stdint.h HAVE_STDINT_H)
check_include_file_cxx (stdlib.h HAVE_STDLIB_H)
check_include_file_cxx (string.h HAVE_STRING_H)
check_include_file_cxx (strings.h HAVE_STRINGS_H) check_include_file_cxx (strings.h HAVE_STRINGS_H)
check_include_file_cxx (sys/stat.h HAVE_SYS_STAT_H) check_include_file_cxx (sys/stat.h HAVE_SYS_STAT_H)
check_include_file_cxx (sys/syscall.h HAVE_SYS_SYSCALL_H) check_include_file_cxx (sys/syscall.h HAVE_SYS_SYSCALL_H)
@ -142,24 +140,24 @@ check_cxx_compiler_flag (-Wunnamed-type-template-args
# NOTE: Cannot use check_function_exists here since >=vc-14.0 can define # NOTE: Cannot use check_function_exists here since >=vc-14.0 can define
# snprintf as an inline function # snprintf as an inline function
check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF) check_symbol_exists (snprintf cstdio HAVE_SNPRINTF)
check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP) check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP)
check_cxx_source_compiles (" check_cxx_source_compiles ("
#include <stdlib.h> #include <cstdlib>
static void foo(void) __attribute__ ((unused)); static void foo(void) __attribute__ ((unused));
int main(void) { return 0; } int main(void) { return 0; }
" HAVE___ATTRIBUTE__) " HAVE___ATTRIBUTE__)
check_cxx_source_compiles (" check_cxx_source_compiles ("
#include <stdlib.h> #include <cstdlib>
static void foo(void) __attribute__ ((visibility(\"default\"))); static void foo(void) __attribute__ ((visibility(\"default\")));
int main(void) { return 0; } int main(void) { return 0; }
" HAVE___ATTRIBUTE__VISIBILITY_DEFAULT) " HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
check_cxx_source_compiles (" check_cxx_source_compiles ("
#include <stdlib.h> #include <cstdlib>
static void foo(void) __attribute__ ((visibility(\"hidden\"))); static void foo(void) __attribute__ ((visibility(\"hidden\")));
int main(void) { return 0; } int main(void) { return 0; }
" HAVE___ATTRIBUTE__VISIBILITY_HIDDEN) " HAVE___ATTRIBUTE__VISIBILITY_HIDDEN)

View File

@ -1,10 +1,10 @@
// Copyright (c) 2008, Google Inc. // Copyright (c) 2008, Google Inc.
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
@ -14,7 +14,7 @@
// * Neither the name of Google Inc. nor the names of its // * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from // contributors may be used to endorse or promote products derived from
// this software without specific prior written permission. // this software without specific prior written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@ -49,9 +49,9 @@
#define BASE_COMMANDLINEFLAGS_H__ #define BASE_COMMANDLINEFLAGS_H__
#include "config.h" #include "config.h"
#include <cstdlib> // for getenv
#include <cstring> // for memchr
#include <string> #include <string>
#include <string.h> // for memchr
#include <stdlib.h> // for getenv
#ifdef HAVE_LIB_GFLAGS #ifdef HAVE_LIB_GFLAGS

View File

@ -149,8 +149,8 @@
// We need to include these header files after defining _XOPEN_SOURCE // We need to include these header files after defining _XOPEN_SOURCE
// as they may define the _XOPEN_SOURCE macro. // as they may define the _XOPEN_SOURCE macro.
#include <assert.h> #include <cassert>
#include <stdlib.h> // for abort() #include <cstdlib> // for abort()
#define MUTEX_NAMESPACE glog_internal_namespace_ #define MUTEX_NAMESPACE glog_internal_namespace_

View File

@ -79,15 +79,9 @@
/* Define to 1 if you have the <stdint.h> header file. */ /* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H} #cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */ /* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H #cmakedefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H
/* Define to 1 if you have the <syscall.h> header file. */ /* Define to 1 if you have the <syscall.h> header file. */
#cmakedefine HAVE_SYSCALL_H #cmakedefine HAVE_SYSCALL_H

View File

@ -34,7 +34,7 @@
// //
// Note that we only have partial C++0x support yet. // Note that we only have partial C++0x support yet.
#include <stdio.h> // for NULL #include <cstdio> // for NULL
#include "utilities.h" #include "utilities.h"
#include "demangle.h" #include "demangle.h"

View File

@ -36,9 +36,9 @@
#ifndef _LOGGING_H_ #ifndef _LOGGING_H_
#define _LOGGING_H_ #define _LOGGING_H_
#include <errno.h> #include <cerrno>
#include <string.h> #include <cstring>
#include <time.h> #include <ctime>
#include <iosfwd> #include <iosfwd>
#include <ostream> #include <ostream>
#include <sstream> #include <sstream>

View File

@ -36,7 +36,7 @@
#ifndef BASE_RAW_LOGGING_H_ #ifndef BASE_RAW_LOGGING_H_
#define BASE_RAW_LOGGING_H_ #define BASE_RAW_LOGGING_H_
#include <time.h> #include <ctime>
@ac_google_start_namespace@ @ac_google_start_namespace@

View File

@ -41,7 +41,7 @@
// // that can't be accomplished e.g. via just VLOG(2) << ...; // // that can't be accomplished e.g. via just VLOG(2) << ...;
// } // }
// //
// The truth value that VLOG_IS_ON(level) returns is determined by // The truth value that VLOG_IS_ON(level) returns is determined by
// the three verbosity level flags: // the three verbosity level flags:
// --v=<n> Gives the default maximal active V-logging level; // --v=<n> Gives the default maximal active V-logging level;
// 0 is the default. // 0 is the default.

View File

@ -32,7 +32,7 @@
#include "utilities.h" #include "utilities.h"
#include <algorithm> #include <algorithm>
#include <assert.h> #include <cassert>
#include <iomanip> #include <iomanip>
#include <string> #include <string>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
@ -44,12 +44,12 @@
#ifdef HAVE_SYS_UTSNAME_H #ifdef HAVE_SYS_UTSNAME_H
# include <sys/utsname.h> // For uname. # include <sys/utsname.h> // For uname.
#endif #endif
#include <time.h> #include <ctime>
#include <fcntl.h> #include <fcntl.h>
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <stdarg.h> #include <cstdarg>
#include <stdlib.h> #include <cstdlib>
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
# include <pwd.h> # include <pwd.h>
#endif #endif
@ -57,7 +57,7 @@
# include <syslog.h> # include <syslog.h>
#endif #endif
#include <vector> #include <vector>
#include <errno.h> // for errno #include <cerrno> // for errno
#include <sstream> #include <sstream>
#ifdef OS_WINDOWS #ifdef OS_WINDOWS
#include "windows/dirent.h" #include "windows/dirent.h"

View File

@ -31,7 +31,7 @@
// The common part of the striplog tests. // The common part of the striplog tests.
#include <stdio.h> #include <cstdio>
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
#include "glog/logging.h" #include "glog/logging.h"

View File

@ -44,18 +44,17 @@
# include <sys/wait.h> # include <sys/wait.h>
#endif #endif
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <fstream>
#include <memory> #include <memory>
#include <queue> #include <queue>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <stdio.h>
#include <stdlib.h>
#include "base/commandlineflags.h" #include "base/commandlineflags.h"
#include "glog/logging.h" #include "glog/logging.h"
#include "glog/raw_logging.h" #include "glog/raw_logging.h"

View File

@ -34,13 +34,13 @@
#include "utilities.h" #include "utilities.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <cstdio>
#include <errno.h> #include <cerrno>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> // for close() and write() # include <unistd.h> // for close() and write()
#endif #endif
#include <fcntl.h> // for open() #include <fcntl.h> // for open()
#include <time.h> #include <ctime>
#include "config.h" #include "config.h"
#include "glog/logging.h" // To pick up flag settings etc. #include "glog/logging.h" // To pick up flag settings etc.
#include "glog/raw_logging.h" #include "glog/raw_logging.h"

View File

@ -36,8 +36,8 @@
#include "symbolize.h" #include "symbolize.h"
#include "glog/logging.h" #include "glog/logging.h"
#include <signal.h> #include <csignal>
#include <time.h> #include <ctime>
#ifdef HAVE_UCONTEXT_H #ifdef HAVE_UCONTEXT_H
# include <ucontext.h> # include <ucontext.h>
#endif #endif

View File

@ -37,9 +37,9 @@
#if defined(HAVE_PTHREAD) #if defined(HAVE_PTHREAD)
# include <pthread.h> # include <pthread.h>
#endif #endif
#include <signal.h> #include <csignal>
#include <stdio.h> #include <cstdio>
#include <stdlib.h> #include <cstdlib>
#include <string> #include <string>
#include "glog/logging.h" #include "glog/logging.h"

View File

@ -35,7 +35,7 @@
// http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK // http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
// Linux has similar code: http://patchwork.ozlabs.org/linuxppc/patch?id=8882 // Linux has similar code: http://patchwork.ozlabs.org/linuxppc/patch?id=8882
#include <stdio.h> #include <cstdio>
#include <stdint.h> // for uintptr_t #include <stdint.h> // for uintptr_t
#include "stacktrace.h" #include "stacktrace.h"

View File

@ -29,8 +29,8 @@
#include "utilities.h" #include "utilities.h"
#include <stdio.h> #include <cstdio>
#include <stdlib.h> #include <cstdlib>
#include "config.h" #include "config.h"
#include "base/commandlineflags.h" #include "base/commandlineflags.h"
#include "glog/logging.h" #include "glog/logging.h"

View File

@ -38,7 +38,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#include <stdio.h> // for NULL #include <cstdio> // for NULL
#include "stacktrace.h" #include "stacktrace.h"
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_

View File

@ -31,10 +31,9 @@
// //
// Produce stack trace using libgcc // Produce stack trace using libgcc
extern "C" { #include <cstdlib> // for NULL
#include <stdlib.h> // for NULL
#include <unwind.h> // ABI defined unwinder #include <unwind.h> // ABI defined unwinder
}
#include "stacktrace.h" #include "stacktrace.h"
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_

View File

@ -56,7 +56,7 @@
#if defined(HAVE_SYMBOLIZE) #if defined(HAVE_SYMBOLIZE)
#include <string.h> #include <cstring>
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
@ -118,14 +118,14 @@ _END_GOOGLE_NAMESPACE_
#else #else
#include <elf.h> #include <elf.h>
#endif #endif
#include <errno.h> #include <cerrno>
#include <climits>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -849,7 +849,7 @@ _END_GOOGLE_NAMESPACE_
#elif defined(OS_MACOSX) && defined(HAVE_DLADDR) #elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
#include <dlfcn.h> #include <dlfcn.h>
#include <string.h> #include <cstring>
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
@ -951,7 +951,7 @@ _END_GOOGLE_NAMESPACE_
#else /* HAVE_SYMBOLIZE */ #else /* HAVE_SYMBOLIZE */
#include <assert.h> #include <cassert>
#include "config.h" #include "config.h"

View File

@ -33,7 +33,7 @@
#include "utilities.h" #include "utilities.h"
#include <signal.h> #include <csignal>
#include <iostream> #include <iostream>
#include "glog/logging.h" #include "glog/logging.h"

View File

@ -31,14 +31,14 @@
#include "utilities.h" #include "utilities.h"
#include <stdio.h> #include <cstdio>
#include <stdlib.h> #include <cstdlib>
#include <signal.h> #include <csignal>
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
# include <sys/time.h> # include <sys/time.h>
#endif #endif
#include <time.h> #include <ctime>
#if defined(HAVE_SYSCALL_H) #if defined(HAVE_SYSCALL_H)
#include <syscall.h> // for syscall() #include <syscall.h> // for syscall()
#elif defined(HAVE_SYS_SYSCALL_H) #elif defined(HAVE_SYS_SYSCALL_H)

View File

@ -34,9 +34,9 @@
#include "utilities.h" #include "utilities.h"
#include <string.h> #include <cstring>
#include <stdlib.h> #include <cstdlib>
#include <errno.h> #include <cerrno>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include "base/commandlineflags.h" #include "base/commandlineflags.h"

View File

@ -27,15 +27,14 @@
#endif #endif
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <cerrno>
#include <stdarg.h> #include <cstdarg>
#include <wchar.h> #include <cstdio>
#include <string.h> #include <cstdlib>
#include <stdlib.h> #include <cstring>
#include <malloc.h> #include <cwchar>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <sys/types.h>
/* Indicates that d_type field is available in dirent structure */ /* Indicates that d_type field is available in dirent structure */
#define _DIRENT_HAVE_D_TYPE #define _DIRENT_HAVE_D_TYPE

View File

@ -1,10 +1,10 @@
/* Copyright (c) 2008, Google Inc. /* Copyright (c) 2008, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
* met: * met:
* *
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above * * Redistributions in binary form must reproduce the above
@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its * * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from * contributors may be used to endorse or promote products derived from
* this software without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@ -37,7 +37,7 @@
#endif #endif
#include "config.h" #include "config.h"
#include <stdarg.h> // for va_list, va_start, va_end #include <cstdarg> // for va_list, va_start, va_end
#include "port.h" #include "port.h"
// These call the windows _vsnprintf, but always NUL-terminate. // These call the windows _vsnprintf, but always NUL-terminate.

View File

@ -1,10 +1,10 @@
/* Copyright (c) 2008, Google Inc. /* Copyright (c) 2008, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
* met: * met:
* *
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above * * Redistributions in binary form must reproduce the above
@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its * * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from * contributors may be used to endorse or promote products derived from
* this software without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@ -54,10 +54,10 @@
#include <io.h> /* because we so often use open/close/etc */ #include <io.h> /* because we so often use open/close/etc */
#include <direct.h> /* for _getcwd() */ #include <direct.h> /* for _getcwd() */
#include <process.h> /* for _getpid() */ #include <process.h> /* for _getpid() */
#include <stdio.h> /* read in vsnprintf decl. before redifining it */ #include <cstdarg> /* template_dictionary.cc uses va_copy */
#include <stdarg.h> /* template_dictionary.cc uses va_copy */ #include <cstdio> /* read in vsnprintf decl. before redifining it */
#include <string.h> /* for _strnicmp(), strerror_s() */ #include <cstring> /* for _strnicmp(), strerror_s() */
#include <time.h> /* for localtime_s() */ #include <ctime> /* for localtime_s() */
/* Note: the C++ #includes are all together at the bottom. This file is /* Note: the C++ #includes are all together at the bottom. This file is
* used by both C and C++ code, so we put all the C++ together. * used by both C and C++ code, so we put all the C++ together.
*/ */