#Internal vs external vs other linkage

14 messages · Page 1 of 1 (latest)

hoary hill
#
  1. Whats the difference between internal, external and other types of linkage (if there are any apart from these 2)?
  2. What exactly does "linkage" mean here?
  3. Why does it matter?
iron swanBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

hoary hill
#

I expected a more understandable answer tbf. Cpp reference is kinda hard to understand for me. I know something about it but i didnt get it fully

silent summit
#

• No linkage: "The name can be referred to only from the scope it is in."
• Internal linkage: "The name can be referred to from all scopes in the current translation unit." I.e. source file.
• External linkage: "The name can be referred to from the scopes in the other translation units."

hoary hill
#

!close

iron swanBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

worthy narwhal
#

Or, in other words, "no linkage" = can't be forward declared, "internal linkage" = can be forward-declared but only in this TU, "external linkage" = can be declared in other TUs too

hoary hill
#

Just to be sure, TU means a source file with included headers in it?

worthy narwhal
#

Yep

silent summit
#

Simply a source file, inclusions are unrelated.

worthy narwhal
silent summit
#

I'm simplifying it.

open jasper
#

From c++20 onwards, module linkage is also a thing