C redefinition errors in Xcode

Hey, I'm encountering an issue with Xcode marking functions from a C codebase I imported as redefinitions even though they are not. I have searched the files and made sure they aren't using any default names that might not be allowed by the compiler.

Example:

int  F_000TODO_EXEDEMO_RUN( void ){

    printf( "[_HELLO_WORLD_]" );
    fflush( stdout );
    return( 0 );
}

error: /Users/[myName]/Developer/work projects/[Project]/[Project]/Algorithm/000TODO/000TODO.c:34:6 Redefinition of 'F_000TODO_EXEDEMO_RUN'

It is also worthy to mention that these errors only appear when I try to compile and when I go into the file to look at them they disappear...

Anyone have any idea what I should try before I use up one of my code level supports for this?

Answered by DTS Engineer in 798908022

I’ve never seen a problem like this that wasn’t caused by folks defining the symbols twice. This is easy to do in C because of the textual nature of its header and macro models. A good way to debug these issues is to choose Product > Perform Action > Preprocess. That’ll show you the source code for a file after it’s been run through the preprocessor, which expands all the headers and macros.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I’ve never seen a problem like this that wasn’t caused by folks defining the symbols twice. This is easy to do in C because of the textual nature of its header and macro models. A good way to debug these issues is to choose Product > Perform Action > Preprocess. That’ll show you the source code for a file after it’s been run through the preprocessor, which expands all the headers and macros.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for the tip. At first it didn't really help me and I was just getting the same errors, so I went down the dependency chain. (I found out that I could compile every single file in the chain without problems, just not the main two)

Turns out the compiler just can't deal with nested dependencies after a certain point. instead of recognising this though, it will give a lot of random errors that don't make much sense on their own. I found this out after just removing the last file in the dependency chain as the features in it aren't done yet and therefore are not in use yet.

It seems like I only get the error that dependencies are nested too deeply when I am exactly one over the apparent limit.

This is going to take me a while to fix because sadly, Xcode can't deal with me copy/pasting the content of the files as it is too much data and Xcode will just crash, but that is a me-problem.

To anyone else reading this: There seems to be a limit of 14 nested dependencies, but I will refactor and give an update on that. This has cost me three days so far...

C redefinition errors in Xcode
 
 
Q