I get the following error when I use constant nVar
instead of a number.
constants.h:
extern const unsigned int nVar;
constants.cpp:
#include "constants.h"
const unsigned int nVar = 5;
main.cpp
#pragma once
#include "constants.h"
void foo(const double q[nVar])
{
// ...
}
Compiler:
array constant is not an integer constant before ']' token
expected ')' before ',' token
expected unqualified-id before 'const'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…