473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Include custom libraries

compman9902
105 100+
Hello, and thank you for viewing this post.
I was just wondering how to make includes for programs (includes like iostream.h, except custom)

I have a few functions that I would like to have in my programs with out adding on a few thousand lines of code, so any help would be great. The only problem is (other then having to idea on how to make includes) is that the functions that I want to make into an includable file need incliudes to run, so, how would I do this??
Jun 17 '07 #1
6 5249
Savage
1,764 Expert 1GB
Hello, and thank you for viewing this post.
I was just wondering how to make includes for programs (includes like iostream.h, except custom)

I have a few functions that I would like to have in my programs with out adding on a few thousand lines of code, so any help would be great. The only problem is (other then having to idea on how to make includes) is that the functions that I want to make into an includable file need incliudes to run, so, how would I do this??
Create a *.h file containing your functions with other includes.

After that just add your won custom include using "name.h" instead of <name.h>

Savage
Jun 17 '07 #2
compman9902
105 100+
Create a *.h file containing your functions with other includes.

After that just add your won custom include using "name.h" instead of <name.h>

Savage
How will the function know what the name of the new variable is?
such as this:
Expand|Select|Wrap|Line Numbers
  1. exampleFunction(string)
  2. {
  3. string = otherExample;
  4. }
  5.  
will that work for displaying the string that the user sends to the function?
Jun 17 '07 #3
Savage
1,764 Expert 1GB
How will the function know what the name of the new variable is?
such as this:
Expand|Select|Wrap|Line Numbers
  1. exampleFunction(string)
  2. {
  3. string = otherExample;
  4. }
  5.  
will that work for displaying the string that the user sends to the function?
I'm not sure that I understand your question.

Can you reform your question?

Savage
Jun 17 '07 #4
compman9902
105 100+
I'm not sure that I understand your question.

Can you reform your question?

Savage
Sure.
When you make a function, a certain variable is usually declared for the variable that the program is passing to the function. Basically, How would the function in the include be able to read the variable passed to it by the program? Please give me code examples. Thank you.
Jun 17 '07 #5
JosAH
11,448 Expert 8TB
Sure.
When you make a function, a certain variable is usually declared for the variable that the program is passing to the function. Basically, How would the function in the include be able to read the variable passed to it by the program? Please give me code examples. Thank you.
You're overcomplicating matters; suppose I have two great functions, foo and bar:

Expand|Select|Wrap|Line Numbers
  1. int foo(double d) { /* great stuff goes on in here ... */ }
  2. int bar(long l) { /* even greater stuff goes on in here */ }
  3.  
I can build a header file foobar.h for those great functions like this:

Expand|Select|Wrap|Line Numbers
  1. #ifndef FOO_BAR
  2. #define FOO_BAR
  3. extern int foo(double);
  4. extern int bar(long);
  5. #endif
  6.  
and all I have to do is to include that header file in other source files:

Expand|Select|Wrap|Line Numbers
  1. #include "foobar.h"
  2.  
  3. int main() {
  4.    int r1= foo(3.1415);
  5.    int r2= bar(12345678L);
  6.    /* other stuff here ... */
  7.    return 0;
  8. }
  9.  
When it comes to linking, the functions foo and bar should be available of course,
maybe in a library or as a compiled translation unit of their own. The compiler
just assumes function foo and bar exist somewhere because I declared them so
in my include file foobar.h. Note the little tag at the top of the include file that
protects the content of the file to be included more than once.

kind regards,

Jos
Jun 17 '07 #6
compman9902
105 100+
You're overcomplicating matters; suppose I have two great functions, foo and bar:

Expand|Select|Wrap|Line Numbers
  1. int foo(double d) { /* great stuff goes on in here ... */ }
  2. int bar(long l) { /* even greater stuff goes on in here */ }
  3.  
I can build a header file foobar.h for those great functions like this:

Expand|Select|Wrap|Line Numbers
  1. #ifndef FOO_BAR
  2. #define FOO_BAR
  3. extern int foo(double);
  4. extern int bar(long);
  5. #endif
  6.  
and all I have to do is to include that header file in other source files:

Expand|Select|Wrap|Line Numbers
  1. #include "foobar.h"
  2.  
  3. int main() {
  4.    int r1= foo(3.1415);
  5.    int r2= bar(12345678L);
  6.    /* other stuff here ... */
  7.    return 0;
  8. }
  9.  
When it comes to linking, the functions foo and bar should be available of course,
maybe in a library or as a compiled translation unit of their own. The compiler
just assumes function foo and bar exist somewhere because I declared them so
in my include file foobar.h. Note the little tag at the top of the include file that
protects the content of the file to be included more than once.

kind regards,

Jos
thanks, just finished it
Jun 17 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Nathan Lamont | last post by:
I would like to make use of two separate PHP applications which happen to share some class names; trying to include both from one script results in the expected error, "cannot redefine class foo."...
43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
1
by: Lüpher Cypher | last post by:
Hi, I just want to make sure I'm getting it right: When I used nested include/include_once, I noticed that, say: /a.php -> include("path/b.php"); /path/b.php -> include("c.php"); /path/c.php...
2
by: satish | last post by:
Hello all, I have a shared object executable viz. *cable* which I execute as follows : $ ansyscust71 -custom cable -p ANSYSRF **ansyscust71 is a shell script and is a part of a software...
4
by: Dave Farrance | last post by:
What's the correct way to find the include directories and link libraries when compiling with gnu c++ ? I decided that I'd like to try out line-drawing using the GTK toolkit, so I copied the...
0
by: Patrick Kearney | last post by:
Hi All, I have seen this type of question raised in various groups but no one has supplied a definitive answer. I am trying to load a dataset schema that has an xs:include. Project policy is to...
6
by: atv | last post by:
Alright, i have some questions concerning include files en global variables.I hope someone is willing to answer these. 1).Why is it that if i define a global variable in a file, say main.c, and...
0
by: Jeremy | last post by:
Hi There, We've got a few web sites that use the same class libraries as well as a few custom server controls. We of course strong name the class libraries as well as custom server controls and...
6
by: Ole Nielsby | last post by:
The standard doesn't define this but what conventions do projects use? As I understand it, #include <somelibrary.h> is used for including system headers and those of frameworks such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.