Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to make a proper Header file in C that contains only my functions????

Status
Not open for further replies.
I had read that function declaration are by default of extern type
means
void lcd_init();
is same as
extern void lcd_init();

am i right...

Both extern and static are two of the five Storage-Class Specifiers, along with auto, register and typedef.

They specify the scope and linkage of the variable or function to which they are applied.

In the case of functions/routines, the function/routine defaults to extern unless specified as static or inline (C99).

Therefore, while syntactically correct, the use of extern in regards to functions/routines is somewhat redundant.

However, the practice is usually continued to provide a level of clarity when declaring functions defined in other files/modules, as with function prototypes.

So, yes you are correct.

you and btbass has told me to create a library file
libr> R lcd.lib lcd.p1

i am not using this right now and my code still works fine so where is the use of this lcd.lib file..
I had not added this file to my project...

I believe I covered this topic in my previous post concerning MikroC's libraries. If not, let me know.

i want a header file in such a way...
that

if i call only a single function then only code size related to that will include...
but at last all functions are included in this...

Is there any solution for that...

i mean to say that

if i am calling lcd_init()
function then code related to that must include in my code memory...
but this is not the case all the functions are included as

we have use
Code:
#define _LCD_INIT
#define _LCD_CLEAR
#define _LCD_DATA_STRING
#define _LCD_FIRST_ROW
#define _LCD_SECOND_ROW

By carefully planning and building a library with separate modules/files, the #define table can be done away with, to include a function/routine contained in a library only requires the inclusion of the function/routine call:

lcd_init();

the above statement would only load the lcd_init module of the LCD library, not the entire libraries collection of routines, thus conserving code space.

I would like to also discuss the use of the Storage-Class Specifier static in regards to functions/routines.

The application of static to a function/routine limits the scope of the function/routine to the module/file where it is defined.

The technique essentially limits access to the function/routine to the module/file where it is defined, therefore you would be able to utilize neither the lcd_cmd() nor lcd_data() within main() if using the source files provided by navnith.

A static function/routine provides a simple form of encapsulation as seen in C++ with the use of the keyword private.

The use of static in regards to functions/routines is often used to prevent naming conflicts with functions/routines within other modules/files and to prevent the use of said functions/routines outside of the module/file they are defined.

BigDog
 

Thanks BigDogGuru..
Nice Explanation..

Thanks for your help
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top