RAD Studio
ContentsIndex
PreviousUpNext
E2238: Multiple declaration for 'identifier' (C++)

This identifier was improperly declared more than once. 

This might be caused by conflicting declarations such as:

  • int a; double a;
  • a function declared two different ways, or
  • a label repeated in the same function, or
  • some declaration repeated other than an extern function or a simple variable
This can also happen by inadvertently including the same header file twice. For example, given:

//a.h
struct A { int a; };
//b.h
#include "a.h"
//myprog.cpp
#include "a.h"
#include "b.h"

myprog.cpp will get two declarations for the struct A. To protect against this, one would write the a.h header file as:

//a.h
#ifndef __A_H
#define __A_H
struct A { int a; };
#endif

This will allow one to safely include a.h several times in the same source code file.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!