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
3
votes
0 answers

why can I use stdio.h without a corresponding stdio.c

When I write a multi module program in c, i use header files for function prototypes and the like, connect things with #includes (using "" not <>), and when i come to compile I compile the .c files together: gcc foo.c bar.c -o name When i include…
3
votes
0 answers

Ruby on Rails as_json include where

My issue I am having is, i want to include all these models when I query my object and return it via my API, but the only issue, is I want to only include on_the_ways where the user_id is not equal to nil. If the user_id is equal to nil, i do not…
Travis Delly
  • 1,194
  • 2
  • 11
  • 20
3
votes
5 answers

Ruby - Count the number of strings in an array that contain either of two characters

I have this array: @a = ["P1 - D", "P3 - M", "P1 - D", "P1 - M", "P1 - D", "P1 - D", "P1 - D", "P1 - D", "P1 - D", "P1 - D", "P1 - D", "P1 - D", "P1 - M", "P2 - D", "P2 - D", "P2 - D", "P2 - M", "P2 - M", "P3 - D", "P3 - D", "P - D", "P1 - M", "P -…
Rubioli
  • 685
  • 6
  • 34
3
votes
4 answers

Why is using std::string still needed after #include ?

In order to use strings I need to include the string header, so that its implementation becomes available. But if that is so, why do I still need to add the line using std::string? Why doesn't it already know about the string data type? #include…
vanmarcke
  • 133
  • 1
  • 1
  • 7
3
votes
1 answer

Weird template include and extends behavior in Django

Gurus, I googled so many times on this issue but I can barely find any useful information. So assume that we have a base.html template as: {% block test %}This is the base!{% endblock %} And 2 child templates under that, a.html and…
Walnut
  • 51
  • 3
3
votes
2 answers

How do I include an external file in PHP?

I need to include and external file that is on another url. For example google.com. I have tested the include using local files, so that much works, but if I try and use 127.0.0.1/filetoinclude.txt Nothing happens. I don't get an error, I just get a…
Sean
  • 8,401
  • 15
  • 40
  • 48
3
votes
1 answer

Entity Framework: Count one collection and Include another?

I have a EF-model with ChatRoom, ChatMessage and Participant. At one point I need to fetch a certain ChatRoom including all its participants but only with a count of the number of messages in it. In my code below, the Room-property is missing its…
Andreas Zita
  • 7,232
  • 6
  • 54
  • 115
3
votes
2 answers

Include multiple files with 1 line

Is it possible to include multiple files by using 1 line in the php file? So lets say my main file is main.php and I want to include ic1.php, ic2.php and ic3.php. I tried creating a new file include_all.php, placed a list with all includes in this…
Johnenzone
  • 39
  • 1
  • 4
3
votes
4 answers

PHP Include Full URL (or website)

I'm trying to do something that I thought was simple but doesn't appear to be so. What I'm wanting is to be able to include a separate website in my PHP code. Basically, the reason for this is that I'm writing a "main" page that has links on it,…
drewrockshard
  • 2,043
  • 10
  • 35
  • 47
3
votes
2 answers

compile protobuf client code on ubuntu, but include file is not found

I just installed google protocol buffer on my ubuntu1604: sudo apt install protobuf-compiler And tried a quick test, 1 proto file, 1 cpp file to use it, try to see the encode/decode results: $ cat 1.proto package x; message my{ required string…
Hind Forsum
  • 9,717
  • 13
  • 63
  • 119
3
votes
0 answers

Why does opencv2/core/eigen.hpp not include Eigen/Core

Whenever I want to use functions like cv::eigen2cv(), #include is not enough and I have to include Eigen as well #include #include Is there any design/compilation reason why…
PhilLab
  • 4,777
  • 1
  • 25
  • 77
3
votes
2 answers

For in twig with include

I need do a cycle for with an include directive in twig but the template twig will not repeat. This is a snippet of my code: ... {% for object in objects %} {% include 'template.html.twig' with {'object':object} %} {% endfor %} ... Only the…
Dasaaf
  • 145
  • 2
  • 11
3
votes
1 answer

how do i include multiple class with the same includes?

How do i include two .h/class files that both have #include "h_file.h"? both require the .h file definitions, and both are included in the main program. how do i prevent the redefinition of the .h definitions (which causes the compiler to not…
calccrypto
  • 8,583
  • 21
  • 68
  • 99
3
votes
3 answers

How can I find duplicate headers in a large solution in MSVC++ 2005 or 2008?

In Visual Studio (C++), is there a way to easily find duplicate headers that are defined in .cpp files? I'm also trying to find ways to detect this situation: A includes B includes C A includes C => A doesn't need to include C
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
3
votes
1 answer

closures with include inside

I have several php files to include and they must act as a function in a protected scope. A closure is intended to load them (include) and execute. Though I encounter a strange effect on coding these closures. All php files ends with a return…