error: 'INT32_MAX' was not declared in this scope
#include <cstdint> //or <stdint.h>
#include <limits>
std::numeric_limits<std::int32_t>::max();
Note that <cstdint>
is a C++11 header and <stdint.h>
is a C header, included for compatibility with C standard library.
Following code works, since C++11.
#include <iostream>
#include <limits>
#include <cstdint>
struct X
{
static constexpr std::int32_t i = std::numeric_limits<std::int32_t>::max();
};
int main()
{
switch(std::numeric_limits<std::int32_t>::max()) {
case std::numeric_limits<std::int32_t>::max():
std::cout << "this code works thanks to constexpr\n";
break;
}
return EXIT_SUCCESS;
}
http://coliru.stacked-crooked.com/a/4a33984ede3f2f7e
‘INTMAX_MAX’ was not declared in this scope
Well, first and foremost, you are compiling your code as C++. Since these macros originate from C99, they can theoretically end up conflicting with existing C++ definitions for the same names. For which reason GCC compiler plays it safe: it wants you to explicitly request these macro definitions before they become available.
In my GCC installation the macro definitions are protected by
#if (!defined __cplusplus || __cplusplus >= 201103L \
|| defined __STDC_LIMIT_MACROS)
Since you are apparently compiling your code as pre-C++11 C++, you have to request these macros by defining __STDC_LIMIT_MACROS
before including stdint.h
. But at the same time your code will compile "as is" if you run the compiler in -std=c++11
mode.
Also see What do __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS mean?
‘ULONG_MAX’ was not declared in this scope
ULONG_MAX
is defined in the limits.h
header file. Putting #include <climits>
in with your other includes should fix the issue.
Error: ‘numeric_limits’ was not declared in this scope
You need to include
#include <limits>
error: FILE was not declared in this scope
Hi fopen
is a function from C I/O standard library (stdio.h).
If you would use that function, in your C++ program, you must include that library #include <cstdio>
.
But in the title you wrote C++, so in this case you can use iostream or fstream like
#include <iostream>
#include <fstream>
Read more here: fopen, stdio.h, cstdio, fstream, iostream.
Good luck!
Related Topics
What Is the Safe Way to Fill Multidimensional Array Using Std::Fill
Which Is Faster: X<<1 or X<<10
In C++ Main Function Is the Entry Point to Program How to Change It to an Other Function
Use Visual Studio 2012 and Compile with Older Platform Toolset
C++ Template Metaprogramming - How to Output the Generated Code
Simpler Way to Create a C++ Memorystream from (Char*, Size_T), Without Copying the Data
C++ Memory Barriers for Atomics
Erase/Remove Contents from the Map (Or Any Other Stl Container) While Iterating It
How to Extend a Lexical Cast to Support Enumerated Types
Passing a Pointer to a Class Member Function as a Parameter
Openmp: What Is the Benefit of Nesting Parallelizations
Adding Static Libcurl to Code::Blocks Ide
How to Declare Constexpr Class in a Header and Define It in a Separate .Cpp File
What Is the Size of an Enum Type Data in C++
How to Build Boost with New Visual Studio 2013 Preview
Of Memory Management, Heap Corruption, and C++
Why Must I Put a Semicolon at the End of Class Declaration in C++