0

I am including dyld.h to provide the function _NSGetExecutablePath() which will give the path to the executable for OS X 10.10.

But when including dyld.h in a C compile, I get the following error:

/usr/include/libkern/i386/_OSByteOrder.h:49:1: error: function definition is not allowed here.

The messages before the above are: In file included from testCode.c:11: In file included from /usr/include/mach-o/dyld.h:31: In file included from /usr/include/mach-o/loader.h:48: In file included from /usr/include/architecture/byte_order.h:38

It appears that dyld.h starts a train of includes that ends with an error. Does anyone know the requirements for using dyld.h or _NSGetExecutablePath()?

virgban
  • 59
  • 7
  • The messages before the above are: In file included from testCode.c:11: In file included from /usr/include/mach-o/dyld.h:31: In file included from /usr/include/mach-o/loader.h:48: In file included from /usr/include/architecture/byte_order.h:38: – virgban Oct 16 '15 at 18:13
  • Please edit your original question, what you've added to the comment is cut off. – Jason D Oct 16 '15 at 18:16
  • Show the code around the error - it sounds like a simple syntax error in your source, such as wrapping the #include in the main. – Anya Shenanigans Oct 18 '15 at 21:36
  • Petesh is correct. I found the syntax error exactly as he suspected. Thank you. – virgban Oct 19 '15 at 21:57

0 Answers0