Questions tagged [include]

A provision that many programming languages provide to allow functionality defined in one file to be used in another.

include is a provision that many programming languages provide to allow functionality (code such as functions, classes, objects etc.) in one file or package to be referenced and used in another.

Example (PHP)

include './dir/file.php';

Resources

9740 questions
148
votes
11 answers

Including one C source file in another?

Is it OK (or even recommended/good practice) to #include a .c file in another .c file?
145
votes
5 answers

Where is PATH_MAX defined in Linux?

Which header file should I invoke with #include to be able to use PATH_MAX as an int for sizing a string? I want to be able to declare: char *current_path[PATH_MAX]; But when I do so my compiler (Clang/LLVM on Linux) issues the following…
haziz
  • 12,994
  • 16
  • 54
  • 75
133
votes
6 answers

How to tell where a header file is included from?

How can I tell where g++ was able to find an include file? Basically if I #include g++ will scan the search path, using any include options to add or alter the path. But, at the end of days, is there a way I can tell the absolute path of…
harschware
  • 13,006
  • 17
  • 55
  • 87
130
votes
9 answers

Where to put include statements, header or source?

Should I put the includes in the header file or the source file? If the header file contains the include statements, then if I include that header file in my source, then will my source file have all of the included files that were in my header? Or…
Mohit Deshpande
  • 53,877
  • 76
  • 193
  • 251
127
votes
19 answers

How do I include a file over 2 directories back?

How do you include a file that is more than 2 directories back. I know you can use ../index.php to include a file that is 2 directories back, but how do you do it for 3 directories back? Does this make sense? I tried .../index.php but it isn't…
Marcus
124
votes
6 answers

Are PHP include paths relative to the file or the calling code?

I'm having trouble understanding the ruleset regarding PHP relative include paths. If I run file A.PHP- and file A.PHP includes file B.PHP which includes file C.PHP, should the relative path to C.PHP be in relation to the location of B.PHP, or to…
Yarin
  • 173,523
  • 149
  • 402
  • 512
118
votes
3 answers

How to define several include path in Makefile

New to C++; Basic understanding of includes, libraries and the compile process. Did a few simple makefiles yet. My current project involves using an informix DB api and i need to include header files in more than one nonstandard dirs. How to write…
groovehunter
  • 3,050
  • 7
  • 26
  • 38
114
votes
8 answers

How to get RelativeLayout working with merge and include?

I have been trying for a few days now to make my layouts more efficient by converting from using several levels of nested LinearLayouts to one RelativeLayout and have come across a few problems that I haven not been able to find a workaround…
Justin
  • 6,564
  • 6
  • 37
  • 34
112
votes
6 answers

C++ #include and #import difference

What is the difference between #include and #import in C++?
Marius
  • 57,995
  • 32
  • 132
  • 151
112
votes
1 answer

Assign variables to child template in {% include %} tag Django

I have this code(which doesn't give me expected result) #subject_content.html {% block main-menu %} {% include "subject_base.html" %} {% endblock %} #subject_base.html .... ....
Vor
  • 33,215
  • 43
  • 135
  • 193
104
votes
3 answers

How to load return array from a PHP file?

I have a PHP file a configuration file coming from a Yii message translation file which contains this: 'value' 'key2' => 'value' ); ?> I want to load this array from another file and store it in a variable I tried…
bman
  • 3,740
  • 9
  • 34
  • 40
103
votes
2 answers

What does "The following object is masked from 'package:xxx'" mean?

When I load a package, I get a message stating that: "The following object is masked from 'package:xxx' For example, if I load testthat then assertive, I get the following: library(testthat) library(assertive) ## Attaching package: ‘assertive’ ##…
Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
102
votes
20 answers

How should I detect unnecessary #include files in a large C++ project?

I am working on a large C++ project in Visual Studio 2008, and there are a lot of files with unnecessary #include directives. Sometimes the #includes are just artifacts and everything will compile fine with them removed, and in other cases classes…
shambolic
  • 1,023
  • 2
  • 9
  • 5
101
votes
16 answers

PHP pass variable to include

I'm trying to pass a variable into an include file. My host changed PHP version and now whatever solution I try doesn't work. I think I've tried every option I could find. I'm sure it's the simplest thing! The variable needs to be set and evaluated…
user1590646
  • 1,011
  • 2
  • 7
  • 4
100
votes
13 answers

PHP - include a php file and also send query parameters

I have to show a page from my php script based on certain conditions. I have an if condition and am doing an "include" if the condition is satisfied. if(condition here){ include "myFile.php?id='$someVar'"; } Now the problem is the server has a…
lostInTransit
  • 70,519
  • 61
  • 198
  • 274