Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Sec0nd on November 11, 2010, 06:45:13 pm

Title: Include automatically
Post by: Sec0nd on November 11, 2010, 06:45:13 pm
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!!!
Title: Re: Include automatically
Post by: stahta01 on November 11, 2010, 07:09:54 pm
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.
Title: Re: Include automatically
Post by: Sec0nd on November 11, 2010, 07:28:35 pm
I'm using the default C++ compiler.( GNU GCC )
The OS is Windows7.
Title: Re: Include automatically
Post by: 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.
Title: Re: Include automatically
Post by: Sec0nd on November 12, 2010, 04:38:42 pm
Sorry, I don't really understand your suggestion:S


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.
Title: Re: Include automatically
Post by: 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"
Title: Re: Include automatically
Post by: 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..
Title: Re: Include automatically
Post by: stahta01 on November 14, 2010, 07:34:43 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.
Title: Re: Include automatically
Post by: Sec0nd on November 14, 2010, 07:40:09 pm
Okay, sorry.
And thanks for trying to help....
Title: Re: Include automatically
Post by: stahta01 on November 14, 2010, 08:41:31 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.