C & C++

C & C++

Made by DeepSource

Found use of deprecated C++ headers CXX-W2030

Anti-pattern
Minor
Autofix

The use of deprecated C++ headers such as signal.h and assert.h is considered an antipattern, as they are not part of the C++ standard library anymore and have been replaced by their C++ equivalents.

This means that they may not be supported by future versions of C++.

Here's a list of such headers,

  • assert.h
  • complex.h
  • ctype.h
  • errno.h
  • float.h
  • limits.h
  • locale.h
  • math.h
  • setjmp.h
  • signal.h
  • stdarg.h
  • stddef.h
  • stdio.h
  • stdlib.h
  • string.h
  • time.h
  • wchar.h
  • wctype.h
  • fenv.h
  • stdint.h
  • inttypes.h
  • tgmath.h
  • uchar.h

Consider using their non .h and c prefixed variants, such as cmath for math.h.

Bad practice

#include <iostream>
#include <assert.h>

int main() {
    int x = 5;
    int y = 6;
    assert(x == y);
    return 0;
}

Recommended

#include <iostream>
#include <cassert>

int main() {
    int x = 5;
    int y = 6;
    assert(x == y);
    return 0;
}