Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Concept of namespace

Concept of namespace

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aakashdata
    wrote on last edited by
    #1

    Does C implement the concept of a namespace?

    L CPalliniC H 3 Replies Last reply
    0
    • A Aakashdata

      Does C implement the concept of a namespace?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Because it has no meaning in C. I suggest you get hold of a book on the language if you want to learn it. The best one ever written is The C Programming Language (2nd Edition): Amazon.co.uk: Brian W. Kernighan, Dennis Ritchie: 8601410794231: Books[^]

      1 Reply Last reply
      0
      • A Aakashdata

        Does C implement the concept of a namespace?

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        Nope, C has nothing similar to C++ namespaces[^]. It has its intrinsic namespaces, see, for instance C Namespaces[^].

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • A Aakashdata

          Does C implement the concept of a namespace?

          H Offline
          H Offline
          harshalipatel
          wrote on last edited by
          #4

          C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.

          L L J 3 Replies Last reply
          0
          • H harshalipatel

            C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.

            L Offline
            L Offline
            leon de boer
            wrote on last edited by
            #5

            You mean you can not have the same name in the same scope. It is routine to carry the same name such as i, j, count etc but they get restricted to within a local scope as a local variable in a function or unit. Not like there should be many but global variables obviously can't have the same name.

            In vino veritas

            1 Reply Last reply
            0
            • H harshalipatel

              C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              It is not a limitation. When C was designed there was not thought to be a need for such a feature. But you could still have variables and functions that were limited to specific source modules. And local variables inside functions were hidden from others automatically.

              1 Reply Last reply
              0
              • H harshalipatel

                C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                Just to be clear namespaces should not be considered a limitation or a feature that is used to protect the scope of variables. Rather it should be considered as a way to protect other entities like classes and methods. If you have a problem with namespace collision in scopes with variables then you need to refactor your code so variables are not exposed at all.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups