128k views
2 votes
Are any C identifiers with block scope visible to the linker? What about file scope?

1) Yes, both block scope and file scope identifiers are visible to the linker
2) No, neither block scope nor file scope identifiers are visible to the linker
3) Yes, only block scope identifiers are visible to the linker
4) Yes, only file scope identifiers are visible to the linker

User Vidya
by
8.0k points

1 Answer

1 vote

Final answer:

Block scope identifiers are not visible to the linker, while non-static file scope identifiers are. The correct answer is that only file scope identifiers without 'static' are visible to the linker.

Step-by-step explanation:

Identifiers in C programming have different scopes, and their visibility to the linker depends on the scope they are declared in. Block scope identifiers are local to the block in which they are defined. This means they are not accessible outside of this block, let alone to the linker, which deals with external linkages. On the other hand, file scope identifiers (also known as global scope) are visible throughout the entire file. If they are declared with the 'static' keyword, they are not visible to the linker because 'static' limits their scope to the file they are declared in. However, non-static file scope identifiers are visible to the linker, as they have external linkage. Therefore, the correct answer is that only file scope identifiers without 'static' are visible to the linker.

User DotNET
by
9.3k points