0

I've a function declared in a file in a directory, say, abc. main/abc/getcm.c

XAPUBLIC int get_cm_name(cm_name)

I've to use this function in another directory, say def. main/def/takecm.c

status = get_cm_name(cm_name)

How can i access this function 'get_cm_name' in 'def' directory using extern. I understand that i can use a header file under 'main' directory to declare this function. Is there an alternative of doing it using extern function.

  • isn't it like functions, unless defined `static` are by default defined with `extern`? – Sourav Ghosh May 17 '16 at 20:14
  • 1
    google for "forward declaration" – user3528438 May 17 '16 at 20:14
  • 1
    XAPUBLIC is not a standard term — is this part of the XA protocol? Is cm_name a type name? – Jonathan Leffler May 17 '16 at 20:18
  • 4
    I think you are misunderstanding the compile process. You can provide search paths for libraries and header files. However, in your case you simply have your *source* files in separate directories. In that case, during compile, you simply need to provide the complete path to each of your required source files so they can be compiled to object and linked into the final executable. – David C. Rankin May 17 '16 at 20:19
  • So how can i provide the complete path to both of the source files. I understand how to add header files using '#include'. – Aseem Rambani May 18 '16 at 03:21
  • 1
    I think i got the answer in this discussion[http://stackoverflow.com/questions/1433204/how-do-i-use-extern-to-share-variables-between-source-files-in-c?rq=1] – Aseem Rambani May 18 '16 at 03:23

0 Answers0