Introduction of myself and question.

This is a discussion on Introduction of myself and question. within the C Programming forums, part of the General Programming Boards category; Hello, I'm new to these forums. I've just started trying to learn "C" and will pick up "C++" as well. ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    2

    Introduction of myself and question.

    Hello, I'm new to these forums. I've just started trying to learn "C" and will pick up "C++" as well.

    My question has to do with the official libraries in "C". The first thing that I noticed as I've been learning "C" is that you have to declare which library to pull functions from, it's slightly different from Python or Matlab in that sense. I thought to myself that if you pull functions from two libraries, and if those libraries both have a function that is named the same thing, the c compiler shouldn't be able to differentiate between which library the function is coming from and this would cause a compiling error, yes? So if there are two functions with the same name in different libraries which you happen to be using in the same code; is it possible to signify to the compiler which library a particular function is supposed to come from?

    Or is this issue avoided altogether in the official libraries by simply giving all functions in all libraries unique names?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Inquisitivenerd View Post
    Or is this issue avoided altogether in the official libraries by simply giving all functions in all libraries unique names?
    Yes. C does not have a hierarchical namespace like C++ and some other languages, whereby functions can be class methods (eg, MyModule::Function), so libraries sometimes must use very long winded names to prevent such collision (eg, myModule_that_function).

    BTW, not very familiar with python but I believe that it does use external libraries via the keyword import. The difference is that python has a huge amount of functionality built into it's core, so you can do quite a bit without having to import anything.

    C, on the other hand, has a stripped down core. You can write programs, however, without using #include at all -- but what you can do is limited. For example, there is no input or output without stdio.h, so whatever such a program does, it cannot affect anything or produce any discernable "result". It can, however, be compiled and ran if you just want to check whether some bit of code will produce compiler or runtime errors.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    2
    I see, thanks for answering my question.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21