The Developer Studio compiles my code with no error and no warning,
but I do not include the needed libraries.
Maybe some standard libraries are loaded by default,
but I cannot find in the settings, and dont know which ones!
Can you help me?

Dani AI

Generated

: the IDE is not "magically" supplying C++ declarations — it is invoking g++ with its normal include paths and linker defaults. That can make code appear to compile even when a header was not explicitly added, because (1) other headers you do include may pull in the declarations you need indirectly, and (2) g++ as the driver automatically links the C++ runtime (libstdc++) for you. is right in intent: explicitly include the headers your code needs to stay portable and future-proof.

Quick diagnostics to see what the compiler actually used (run in a MinGW shell or Windows command prompt):

g++ -H myfile.cpp
echo | g++ -v -x c++ -E -
g++ myfile.cpp -o myfile.exe -Wl,--verbose 2>&1 | more

-H prints every header file the compiler pulls in. -v -E shows search paths and any -include options. Passing --verbose to the linker reveals which libraries are being pulled in. Also check the Developer Studio build log to see the exact g++ command line the IDE runs.

If by "limit" you meant std::numeric_limits, include <limits>; for C macros like INT_MAX include <climits> or <limits.h>. See the standard reference for numeric_limits here: numeric_limits - cppreference.com. For the compiler options that control automatic includes and preprocessor behavior, see GCC's preprocessor options: Preprocessor Options - GCC.

Practical rule: add the correct header, enable warnings (-Wall -Wextra -pedantic) and treat warnings as errors during development to catch fragile, indirectly-satisfied dependencies.

Recommended Answers

All 2 Replies

Um, just include the libraries you know are needed. Consider this a lesson in writing portable code: the compiler is not a replacement for your brain.

For example "limit"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.