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
76
votes
8 answers

What are the benefits of a relative path such as "../include/header.h" for a header?

I've reviewed questions How to use include directive correctly and C++ #include semantics and neither addresses this - nor do the others suggested by SO when I typed the title... What, if any, are the benefits of writing: #include…
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
75
votes
1 answer

Dump include paths from g++

I'm trying to write a little build script, and want to determine if the includes are system includes or not. So I want g++ to tell me the include path's it's using. cpp -v seems the obvious best shot, but it doesn't give me the C++ paths. So I…
Oliver
  • 2,361
  • 2
  • 17
  • 12
71
votes
6 answers

c++ header files including each other mutually

I have two classes both defined in separate header files. Each file has a field that is type of other class. Now I included in header of each file the header of other file, but compiler is generating errors. What am i missing?
MegaManX
  • 8,766
  • 12
  • 51
  • 83
68
votes
4 answers

Extend a java class from one file in another java file

How can I include one java file into another java file? For example: If I have 2 java file one is called Person.java and one is called Student.java. How can I include Person.java into Student.java so that I can extend the class from Person.java in…
Jin Yong
  • 42,698
  • 72
  • 141
  • 187
67
votes
15 answers

Cannot find corecrt.h: $(UniversalCRT_IncludePath) is wrong

I've just installed Visual Studio 2015 on my working laptop with Windows 10. I've cloned a repository with a solution created with the same version of Visual Studio (update 3) on another PC, always with windows 10. When I try to build the solution…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
66
votes
18 answers

"Fatal error: Cannot redeclare "

I have a function(this is exactly how it appears, from the top of my file):
fishman
  • 955
  • 1
  • 7
  • 13
66
votes
7 answers

How to set include path in xcode project

I am trying to use a C library in an Objective-C Xcode project. The libraries directory structure is as follows: -- include/ |-- config.h |-- lib/ | |-- file1.h | |-- file2.h | |-- file3.h The library's docs say to…
RyanM
  • 4,474
  • 4
  • 37
  • 44
64
votes
11 answers

Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0

I am trying to include a php file in a page via require_once(http://localhost/web/a.php) I am getting an error Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 I changed…
Gags
  • 3,759
  • 8
  • 49
  • 96
64
votes
15 answers

Eclipse CDT: Symbol 'cout' could not be resolved

The error is as above. I have what should be all the necessary files include in the eclipse project: /usr/include/c++/4.6 /usr/include /usr/include/linux /usr/local/include etc. I tried std::cout and using namespace std; cout but it still says…
Jeff
  • 1,251
  • 1
  • 12
  • 22
63
votes
7 answers

Include relative files in PowerShell

I would like to include script files with such pseudo syntax: Include '.\scripA.ps1' But the only thing I have found is some thing like this: $thisScript = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent . ($thisScript +…
alex2k8
  • 42,496
  • 57
  • 170
  • 221
62
votes
2 answers

Should I include or in C++ programs?

What should I include in C++ programs, stdio.h or cstdio? and Why? Why two header files which provide the same functionality? What does the standard say regarding this? How should I go about including other such headers,…
Alok Save
  • 202,538
  • 53
  • 430
  • 533
61
votes
7 answers

How do include paths work in Visual Studio?

Visual Studio drives me crazy and I am suspecting I am doing something wrong. This is what I do: I installed Visual Studio (Pro '08) a long time ago, I installed the Windows SDK (Win 7 x64), someone emails me a project, it fails to…
bastibe
  • 16,551
  • 28
  • 95
  • 126
60
votes
4 answers

Including a header file from another directory

I have a main directory A with two sub directories B and C. Directory B contains a header file structures.c: #ifndef __STRUCTURES_H #define __STRUCTURES_H typedef struct __stud_ent__ { char name[20]; int roll_num; }stud; #endif Directory C…
Manny
  • 639
  • 2
  • 6
  • 7
60
votes
3 answers

Why create an include/ directory in C and C++ projects?

When I work on my personal C and C++ projects I usually put file.h and file.cpp in the same directory and then file.cpp can reference file.h with a #include "file.h" directive. However, it is common to find out libraries and other kinds of projects…
user4546925
60
votes
7 answers

Headers Including Each Other in C++

I'm a C++ newbie, but I wasn't able to find the answer to this (most likely trivial) question online. I am having some trouble compiling some code where two classes include each other. To begin, should my #include statements go inside or outside…
Scott
  • 2,551
  • 5
  • 25
  • 25