News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Include automatically

Started by Sec0nd, November 11, 2010, 06:45:13 PM

Previous topic - Next topic

Sec0nd

I learn c++ in my school, there we use DevC++.
I heard from Code::blocks from my friend and I want to use it at home, but in school we use system("pause") command, but Code::Blocks isn't familiar with it.I wan't to use my files both of IDE.
So how can I set that Code::Block include automatically <stdlib.h>, without writing it to the source file?

Thank You for helping!!!

stahta01

#1
Learn the difference between an Compiler and the Code::Blocks IDE.

Learn to Always include the correct header for the functions you use even if it works sometimes without using the proper headers!

Learn to mention the OS and Compiler you are using when asking an question about how to do something that has to do with your compiler/OS and little to do with Code::Blocks!

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Sec0nd

I'm using the default C++ compiler.( GNU GCC )
The OS is Windows7.

stahta01

Try GCC Option "include" in Code::Blocks, IIRC in the extra Compile area.

http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options

Quote
-include file
    Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.

    If multiple -include options are given, the files are included in the order they appear on the command line.

No idea if the above does what you want; this is NOT really a Code::Blocks question.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Sec0nd

Sorry, I don't really understand your suggestion:S


Quote from: stahta01 on November 11, 2010, 09:30:24 PM
Try GCC Option "include" in Code::Blocks, IIRC in the extra Compile area.

http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options

Quote
-include file
    Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.

    If multiple -include options are given, the files are included in the order they appear on the command line.

No idea if the above does what you want; this is NOT really a Code::Blocks question.

Tim S.

stahta01

Try placing "-include stdlib.h" without the double quotes in the Other Options section.

Project -> Build Option
Tab "Compiler Settings"
Sub Tab "Other Options"
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Sec0nd

Thanks, but I don't use projects, I'm a beginner.
We work with several source files..

stahta01

Quote from: Sec0nd on November 14, 2010, 05:35:11 PM
Thanks, but I don't use projects, I'm a beginner.
We work with several source files..

So long then; because if you do NOT want to use projects; then in my opinion you have no real reason to use Code::Blocks or to expect help from the website.
You wasted a lot of my time by NOT saying the fact you do NOT use projects right at first.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Sec0nd

Okay, sorry.
And thanks for trying to help....

stahta01

Quote from: stahta01 on November 13, 2010, 11:47:44 PM
Try placing "-include stdlib.h" without the double quotes in the Other Options section.

Project -> Build Option
Tab "Compiler Settings"
Sub Tab "Other Options"


You can also use the option in the Compiler Settings; this should work without a project. I have never tried it before.

Settings -> Compiler and Debugger
Tab "Compiler Settings"
Sub Tab "Other Options"


Never ask why the debugger does NOT work; it requires a project to work.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]