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
98
votes
1 answer

Including #includes in header file vs source file

I like to put all my #includes in my header file then only include my header for that source file in my source file. What is the industry standard? Are there any draw backs to my method?
Rob from Utah
  • 981
  • 1
  • 7
  • 3
93
votes
3 answers

Include header files using command line option?

Is it possible to specify extra header files to include from the command line (using GCC 4 / C++)? Or is there any other way files can be included except with #include? Background: I'm trying to compile a large code base on my own PC. The code is…
jdm
  • 9,470
  • 12
  • 58
  • 110
91
votes
5 answers

How to include constraint layout to another constraint layout and set constraint between each

I'm using constraintLyout v 1.0.1. I would like to include in my xml a sub ConstraintLayout corresponding to a part of my global layout (which itself is a ConstraintLayout). I split the layout in two xmls in order to use this sub part elsewhere I…
Kélian
  • 3,323
  • 3
  • 11
  • 20
91
votes
4 answers

Where are include files stored - Ubuntu Linux, GCC

So, when we do the following: #include versus #include "myFile.h" the compiler, GCC in my case, knows where that stdio.h (and even the object file) are located on my hard drive. It just utilizes the files with no interaction from me. I…
Frank V
  • 25,141
  • 34
  • 106
  • 144
90
votes
5 answers

EF: Include with where clause

As the title suggest I am looking for a way to do a where clause in combination with an include. Here is my situations: I am responsible for the support of a large application full of code smells. Changing too much code causes bugs everywhere so I…
Beejee
  • 1,836
  • 2
  • 17
  • 31
89
votes
9 answers

Can the C preprocessor be used to tell if a file exists?

I have a very large codebase (read: thousands of modules) that has code shared across numerous projects that all run on different operating systems with different C++ compilers. Needless to say, maintaining the build process can be quite a chore.…
Lisa
87
votes
1 answer

Project reference conditional include with multiple conditions

Here's a snippet from my csproj file: {4F9034E0-B8E3-448E-8794-CF9B9A5E7D46}
Charlie Salts
  • 13,109
  • 7
  • 49
  • 78
86
votes
5 answers

Passing a variable from one php include file to another: global vs. not

I'm trying to pass a variable from one include file to another. This is NOT working unless I declare the variable as global in the second include file. However, I do NOT need to declare it as global in the file that is calling the first include. For…
maxedison
  • 17,243
  • 14
  • 67
  • 114
86
votes
12 answers

How to get the file-path of the currently executing javascript code

I'm trying to do something like a C #include "filename.c", or PHP include(dirname(__FILE__)."filename.php") but in javascript. I know I can do this if I can get the URL a js file was loaded from (e.g. the URL given in the src attribute of the tag).…
B T
  • 57,525
  • 34
  • 189
  • 207
84
votes
6 answers

How to include WordPress functions in custom .php file?

How can I include WordPress functions in a custom .php file? In detail: I have a directory under my theme (Constructor) named reports. These contain .php files that generate reports from data from the site with DOMPDF for downloading. For these I…
Sziro
  • 1,273
  • 1
  • 13
  • 21
83
votes
4 answers

cmath vs math.h (And similar c-prefixed vs .h extension headers)

I've seen some information about differences between things like iostream vs iostream.h. From what I gathered from those the difference between them is that the version without the .h extension will not populate the namespace while the version with…
golmschenk
  • 11,736
  • 20
  • 78
  • 137
80
votes
3 answers

Why would one use #include_next in a project?

To quote the iOS Documentation on Wrapper Headers: #include_next does not distinguish between and "file" inclusion, nor does it check that the file you specify has the same name as the current file. It simply looks for the file named,…
CodaFi
  • 43,043
  • 8
  • 107
  • 153
79
votes
4 answers

How can I programmatically include layout in Android?

I'm looking for a way to include a layout programmatically instead of using the XML tag include like in my example:
slama007
  • 1,273
  • 2
  • 18
  • 34
78
votes
10 answers

How do I include functions from another file in my Perl script?

This seems like a really simple question but somehow my Google-Fu failed me. What's the syntax for including functions from other files in Perl? I'm looking for something like C's #include "blah.h" I saw the option for using Perl modules, but that…
Zain Rizvi
  • 23,586
  • 22
  • 91
  • 133
77
votes
5 answers

Simple example of and usage in Android XML-layouts

I'm curious about the and tags in Android XML-layouts. I've read two tutorials, but haven't yet found a simple example usage. Would be happy if someone could provide such an example or give a pointer to one.
aioobe
  • 413,195
  • 112
  • 811
  • 826