user147502
user147502

Reputation: 1118

solving identifier "xxx" is undefined

I am experiencing something weird that I dont quite understand.

I am getting errors like:

framework/CP_STLArrayDefines.h(37): error: identifier "CP_String" is undefined
    typedef std::vector<CP_String, std::allocator<CP_String> >                      CP_Strings_Array;
                        ^
framework/CP_STLArrayDefines.h(37): error: identifier "CP_String" is undefined
    typedef std::vector<CP_String, std::allocator<CP_String> >

But if I go look in CP_STLArrayDefines, I am clearly doing:

#include "CP_String.h"

if I go look at CP_String.h and .cpp they seem fine.

They are both in the same directory, etc.

What things should I look for?

Here is CP_STLArrayDefine.h:

#ifndef CP_STLArrayDefines_H
#define CP_STLArrayDefines_H

#ifndef TARGET_OS_LINUX
#   pragma once
#endif

// CPLAT_Framework
#include "CP_Point.h"
#include "CP_String.h"
#include "CP_Types.h"

// Standard Library
#include <vector>

CPLAT_Begin_Namespace_CPLAT

    // typedefs
#if ! TARGET_OS_LINUX
    typedef std::vector`<CP_String, std::allocator<`CP_String>` >`                      CP_Strings_Array;
    typedef std::vector`<CP_String, std::allocator<`CP_String>` >`::iterator            CP_Strings_Iterator;
    typedef std::vector`<CP_String, std::allocator<`CP_String>` >`::reverse_iterator    CP_Strings_ReverseIterator;

Upvotes: 2

Views: 20360

Answers (4)

A. Levy
A. Levy

Reputation: 30646

I don't have enough information to give you an answer, but I'll make a wild guess as to a possible cause for the errors you are seeing. Is CP_String declared inside a namespace? If so what is it? I see the macro invocation: CPLAT_Begin_Namespace_CPLAT, which I assume does something like using namespace CPLAT; and maybe some standard setup. Perhaps, due to the reorganization you mentioned in your comments, CP_String is no longer in the CPLAT namespace, and so the compiler cannot find it.

Upvotes: 0

Troubadour
Troubadour

Reputation: 13431

If you are certain that it's not a circular include then remember you can always fall back to that often overlooked technique of using the appropriate compiler switch to just dump out the preprocessed source i.e. have it stop before doing the compilation phase. Search through the output of that and you'll find out why the compiler's complaining as you're now looking at what the compiler sees.

The option is /E in MSVC and -E with gcc.

Upvotes: 4

Paulius
Paulius

Reputation: 5870

Is CP_String.h properly guarded? I mean, the header multi-inclusion guards, of course.

Could it be, that one of the headers included before CP_String.h has the same symbol used in the guards (that happens, when you're copy-pasting include guards from one header to another).

Upvotes: 1

sth
sth

Reputation: 229914

Does maybe also CP_String.h include CP_STLArrayDefines.h, so that both files try to include each other? With include guards in the header files this could lead to an error like you describe.

Upvotes: 2

Related Questions