answersLogoWhite

0


Best Answer

Ideally, functions should only be declared in a header and defined in a translation unit (source file) that includes the header. However, trivial functions are often defined in a header as they are usually good candidates for inline expansion, but you must remember to declare the function inline. Often it is better to forward declare inline functions so that maintainers are not distracted by the implementation details which can be placed towards the end of the header, out of the way. However, a definition is also a declaration, so forward declaring an inline function is not a requirement unless there is a cyclic dependency issue where a forward declaration is necessary to break the cycle.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

declared

Your question hardly makes any sense, but one thing is clear: functions cannot be nested, so inside function main there cannot be any more function-definitions, only function-declarations.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

In header files the functions are declared not defined. Functions are defined in the library routines only.

This answer is:
User Avatar

User Avatar

Wiki User

17y ago

Functions in C are declared in header files. The body of a function has it's own .c file (extracted from a library at run-time)

This answer is:
User Avatar

User Avatar

Wiki User

16y ago

In header files the functions are declared not defined, it will be defined in the library/c routines file only. Ram kumar

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In a header file whether functions are declared or defined?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can an extern function be defined in a C header file?

Declared is the right word. (Don't define functions in headers, unless you really know what you are doing.)


Why you use header files in c?

the use of header files is to add functionality. Header files are basically saying put code in that header file here so you don't have to type that many lines of code.


Which header file is FILE declared in?

The FILE type is declared in stdio.h.


Can static variables be declared in header file?

Can static variables be declared in a header file?You can't declare a static variable without defining it as well (this is because the storage class modifiersstatic and extern are mutually exclusive). A static variable can be defined in a header file, but this would cause each source file that included the header


Is a header file a collection of built in functions that help in writing c programs?

No. There are no built-in functions in C, there are only built-in types and built-in operators for those types. All functions are user-defined, including those defined by the C standard library. There are no user-defined operators in C, but you can implement operators as named functions if required. A header file (*.h file) typically contains a group of related user-defined function and/or user-defined type declarations which can be included in any source file that requires them. Every user-defined function or user-defined type name used by a program must have one (and only one) definition, usually contained in a corresponding source file (*.c file) or library file (*.lib file). Built-in types and their corresponding operators do not require a header file since they are part of the language itself (hence they are built-in).

Related questions

In header files whether functions are declared or defined in c language?

Rephrase your question so it is comprehensible.


Are functions defined or declared in header files-oops?

Usually declared only-oops.


Can an extern function be defined in a C header file?

Declared is the right word. (Don't define functions in headers, unless you really know what you are doing.)


What is headderfile in c language?

Header File in C/C++ are the files which contains the definition of the pre-defined functions, data-types & constants, etc. By adding the header file you reduce your job of defining the same functions which are defined earlier by someone else & you can use those functions/data-types easily.


Which header files contain declaration for the files input and output functions and the macros defined and that are used with file input and output functions?

stdio.h


What is header file in computer programming?

A header file is used in some languages to declare functions that will be used but are not yet defined in the current source code. This is primarily used by C and C++, and usually for library functions and user-defined functions that are stored in separate files and folders than the main source code file.


Why you use header files in c?

the use of header files is to add functionality. Header files are basically saying put code in that header file here so you don't have to type that many lines of code.


What is the importance of header file?

A header file is a library of a no. of functions, which could be used (once or more than once) in some or the other programs. Thus, instead of defining all functions separately we can assemble them in a single library, the header file. These can be predefined or user defined. Hence, it reduces the line of codes and also the complexity.


Which header file is FILE declared in?

The FILE type is declared in stdio.h.


Can static variables be declared in header file?

Can static variables be declared in a header file?You can't declare a static variable without defining it as well (this is because the storage class modifiersstatic and extern are mutually exclusive). A static variable can be defined in a header file, but this would cause each source file that included the header


Is a header file a collection of built in functions that help in writing c programs?

No. There are no built-in functions in C, there are only built-in types and built-in operators for those types. All functions are user-defined, including those defined by the C standard library. There are no user-defined operators in C, but you can implement operators as named functions if required. A header file (*.h file) typically contains a group of related user-defined function and/or user-defined type declarations which can be included in any source file that requires them. Every user-defined function or user-defined type name used by a program must have one (and only one) definition, usually contained in a corresponding source file (*.c file) or library file (*.lib file). Built-in types and their corresponding operators do not require a header file since they are part of the language itself (hence they are built-in).


Can Header file be called in main function or not?

No, main.c does not require a header file. When you have a ".c" and ".h" pair, the ".h" file is to declare the existence of functions that are defined in the ".c" files so that these functions can be called in other files. since "main.c" needs the headers of the other modules (to access their data types and functions) but usually doesn't have a header file itself.Header files aren't "called", they are "included",but usually not inside any function.