How does the function of determining the function name work in several C files?
I am migrating the standard gnu toolchain project to iPhone OS and use Xcode to do this.
The code builds through make, but not through xcode. when building through xcode, the linker complains that the same character (function) is defined in two objects. The code has two different source files, which #includeare a common file between them. Although ... weird (at least for me) seems to work for a standard toolchain. any ideas if this is something that is somehow handled differently via the standard makefile?
#include
Makefile, XCode, , , , - . Makefile, , 'gcc'. , , #ifdef, XCode.
, , ( ). , , , .
.
, , . : common.h
common.h
int foo = 42;
:
extern int foo; // a declaration
common.c, :
common.c
C, , static , , . , file1.c
static
file1.c
void fn1() {} static void fn2() {}
file2.c
-
cc file1.c file2.c
fn1 file1.c fn1 file2.c, fn2 ( ). (, , , .)
fn1
fn2
I assume that the generic header defines an inline function that results in duplicate characters. If so, prefix these functions with static inlineor define them as inlinewith a declaration externin another .c file.
static inline
inline
extern
Source: https://habr.com/ru/post/1703718/More articles:How to distribute asdf / quicklisp dependencies with an application compiled with Embeddable Common Lisp? - lispSegfault from adding a variable - cThe most reliable way to check for an integer - vb.netHow to embed a mini-console in a Java application? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1703717/mouseleftbuttondown-on-canvas-requires-too-much-precision&usg=ALkJrhiycvcajbCWxObvZBdcO2ixSCZzPAObfuscating source code when publishing (C #) - c #Converting an object of type Object to another type using an object of type - castingWhat is a good Cnet Telnet client implementation? - c #VS2005 C ++ broken vtables - c ++Can I define a datagrid column that is sorted in Silverlight? - sortingAll Articles