V
Vladimir Jovic
Hello,
Consider next example (consisting of 3 source and 2 header files) :
/////// fda0.hpp
#ifndef FDA0
#define FDA0
extern const unsigned int TOTAL_SIZE;
#endif
/////// fda0.cpp
#include "fda0.hpp"
const unsigned int TOTAL_SIZE( 10 );
/////// fda1.hpp
#ifndef FDA1
#define FDA1
#include "fda0.hpp"
struct A
{
void print();
unsigned int buffer[ TOTAL_SIZE ];
};
#endif
/////// fda1.cpp
#include "fda1.hpp"
#include <iostream>
void A:rint()
{
for ( unsigned int i=0; i < TOTAL_SIZE; ++ i )
{
std::cout<<buffer<<" ";
}
std::cout<<std::endl;
}
/////// fda2.cpp
#include "fda1.hpp"
int main()
{
A a;
a.print();
}
I am using g++ 4.3.0 to compile it as:
g++ fda0.cpp fda1.cpp fda2.cpp
and the error I am getting is next:
g++ fda1.cpp fda0.cpp fda2.cpp
In file included from fda1.cpp:3:
fda1.hpp:11: error: array bound is not an integer constant
fda1.cpp: In member function ‘void A:rint()’:
fda1.cpp:11: error: ‘buffer’ was not declared in this scope
In file included from fda2.cpp:3:
fda1.hpp:11: error: array bound is not an integer constant
What is the cause of this error and how to fix it?
Thanks in advance
Consider next example (consisting of 3 source and 2 header files) :
/////// fda0.hpp
#ifndef FDA0
#define FDA0
extern const unsigned int TOTAL_SIZE;
#endif
/////// fda0.cpp
#include "fda0.hpp"
const unsigned int TOTAL_SIZE( 10 );
/////// fda1.hpp
#ifndef FDA1
#define FDA1
#include "fda0.hpp"
struct A
{
void print();
unsigned int buffer[ TOTAL_SIZE ];
};
#endif
/////// fda1.cpp
#include "fda1.hpp"
#include <iostream>
void A:rint()
{
for ( unsigned int i=0; i < TOTAL_SIZE; ++ i )
{
std::cout<<buffer<<" ";
}
std::cout<<std::endl;
}
/////// fda2.cpp
#include "fda1.hpp"
int main()
{
A a;
a.print();
}
I am using g++ 4.3.0 to compile it as:
g++ fda0.cpp fda1.cpp fda2.cpp
and the error I am getting is next:
g++ fda1.cpp fda0.cpp fda2.cpp
In file included from fda1.cpp:3:
fda1.hpp:11: error: array bound is not an integer constant
fda1.cpp: In member function ‘void A:rint()’:
fda1.cpp:11: error: ‘buffer’ was not declared in this scope
In file included from fda2.cpp:3:
fda1.hpp:11: error: array bound is not an integer constant
What is the cause of this error and how to fix it?
Thanks in advance