Show: Object Pascal C++
Display Preferences

E2238 Multiple declaration for 'identifier' (C++)

From Appmethod Topics
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

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.

Personal tools
In other languages