answersLogoWhite

0

A function's declaration must be visible within every translation unit that uses that function, thus multiple declarations are permitted. To ensure consistency across all translation units that use a function, the declaration is usually placed in a header which can be included wherever it is needed. Formal arguments need not be named in a declaration (they do not form part of the function's prototype), but named arguments can provide better documentation and need not match the names used by the definition, or indeed by any other declaration of the same function.

Note that a definition is itself a declaration, thus if a function is declared (but not yet defined), there has to be at least two declarations because the function must be defined somewhere.

The "one definition rule" (ODR) implies there can only ever be one definition of a function, however multiple definitions are permitted provided those definitions appear in different translation units and are token-for-token identical (including the names of formal arguments). Being token-for-token identical means there is only one definition.

Thus the correct answer is D: multiple declarations with one definition.

User Avatar

Wiki User

7y ago

What else can I help you with?

Continue Learning about Engineering

How do you define the definition section of a c program?

C programs don't have a definition section as such. C source files are composed from declarations and definitions, however the only requirement is that all user-defined identifiers be declared before they are used; the definition itself can literally be placed anywhere. However, a definition is itself a declaration so we really only need declarations when a definition is used by two or more source files or where two or more definitions refer to each other (cyclic dependants). Typically, we place declarations in header files which can then be included (via the #include compiler directive) in any source files that require them, thus ensuring all declarations are consistent. By organising declarations by their function we can include all related identifiers with a single #include directive. Declarations that are not actually used don't cost anything because declarations do not generate code. Definitions do generate code, but if the code is not used the only cost is in generating the code because unused code has neither internal or external linkages.


Is it true global variable may have several declaration but only one definition?

Yes, indeed it is. In all the declarations, you need to use the keyword "extern". Rgds, Karthick S.


What is Variable declaration and variable initialization?

...are important things in programming. Example: extern int variable; /* declaration */ int variable= 8; /* definition with initialization */


Difference between library file and header file?

EX: pgm #include<stdio.h> main() { printf("haiii"); } Header file: (1) contains the function(printf) declaration (2) during preprocessing, the printf function is replaced by the function declaration Library file : (1) contains the function(printf) definition (2) during linking, the function declaration is replaced with the function definition.obviously, everything will be in object while linking


What are invalid variable names?

Invalid variable names are identifiers that are not recognised by the language compiler. All user-defined identifiers (both names and type definitions) must be introduced to the compiler by a declaration. A definition is also a declaration, however a definition is not required to use a name, only the declaration. However, all declarations must be defined somewhere. Different programming languages have different conventions for naming identifier. However, in most languages, a name must always begin with a letter or an underscore, never a digit, because a leading digit usually signifies a value and would only complicate the language compiler's implementation. Case-sensitive languages, such as C treat 'name', 'Name' and 'NAME' as being different identifiers while case-insensitive languages will treat them as being the same identifier.

Related Questions

How do you define the definition section of a c program?

C programs don't have a definition section as such. C source files are composed from declarations and definitions, however the only requirement is that all user-defined identifiers be declared before they are used; the definition itself can literally be placed anywhere. However, a definition is itself a declaration so we really only need declarations when a definition is used by two or more source files or where two or more definitions refer to each other (cyclic dependants). Typically, we place declarations in header files which can then be included (via the #include compiler directive) in any source files that require them, thus ensuring all declarations are consistent. By organising declarations by their function we can include all related identifiers with a single #include directive. Declarations that are not actually used don't cost anything because declarations do not generate code. Definitions do generate code, but if the code is not used the only cost is in generating the code because unused code has neither internal or external linkages.


What is Unilateral Declaration of Independence?

That is a tautology. All declarations of independence are unilateral by definition. It just means one-sided.


Is it true global variable may have several declaration but only one definition?

Yes, indeed it is. In all the declarations, you need to use the keyword "extern". Rgds, Karthick S.


What is Variable declaration and variable initialization?

...are important things in programming. Example: extern int variable; /* declaration */ int variable= 8; /* definition with initialization */


C programming language bsc it notes?

different between defining value definition section and defining value declaration section


Difference between library file and header file?

EX: pgm #include<stdio.h> main() { printf("haiii"); } Header file: (1) contains the function(printf) declaration (2) during preprocessing, the printf function is replaced by the function declaration Library file : (1) contains the function(printf) definition (2) during linking, the function declaration is replaced with the function definition.obviously, everything will be in object while linking


What are invalid variable names?

Invalid variable names are identifiers that are not recognised by the language compiler. All user-defined identifiers (both names and type definitions) must be introduced to the compiler by a declaration. A definition is also a declaration, however a definition is not required to use a name, only the declaration. However, all declarations must be defined somewhere. Different programming languages have different conventions for naming identifier. However, in most languages, a name must always begin with a letter or an underscore, never a digit, because a leading digit usually signifies a value and would only complicate the language compiler's implementation. Case-sensitive languages, such as C treat 'name', 'Name' and 'NAME' as being different identifiers while case-insensitive languages will treat them as being the same identifier.


What are variable name?

Invalid variable names are identifiers that are not recognised by the language compiler. All user-defined identifiers (both names and type definitions) must be introduced to the compiler by a declaration. A definition is also a declaration, however a definition is not required to use a name, only the declaration. However, all declarations must be defined somewhere. Different programming languages have different conventions for naming identifier. However, in most languages, a name must always begin with a letter or an underscore, never a digit, because a leading digit usually signifies a value and would only complicate the language compiler's implementation. Case-sensitive languages, such as C treat 'name', 'Name' and 'NAME' as being different identifiers while case-insensitive languages will treat them as being the same identifier.


10 example of a predefined function in a c?

1. Cat2. Cake3. Closet4. Coffin5. Cuckoon6. Cukoo Clock7. Clock8. Case9. Card10. ClothesThere we go, then things starting with C, if that is what you were asking for, but if its not, i would make your question more understandable, maybe change some words.Bye x


What is the definition of searching and sorting vb?

There is no special definition for VB; it is the same as in any other programming language - and the definition is similar to the commonly used definitions (i.e., outside of computer programming). Something like this: Search: try to find information. Sort: Reorganize data items in such a way that each data item is larger than the one before it.


In c plus plus Who tells the compiler that a specific class will be declared later in the program?

A forward declaration. However forward declarations can only be used when the class is used as a pointer or reference prior to its definition, otherwise it must be defined before it is used. class A; // forward declaration class B { A& data; // reference to class that has yet to be defined }; class A {}; // definition


What is definition of global diplomacy?

definitions of diplomacy