Defining a static array into a C or C++ source file.

Posted by VansFannel on Stack Overflow See other posts from Stack Overflow or by VansFannel
Published on 2011-01-10T09:51:11Z Indexed on 2011/01/10 9:53 UTC
Read the original article Hit count: 165

Filed under:
|
|
|

Hello.

I know this is a question that every programmer should know, but I do not know. Long time no C programming and I've forgotten a lot of things.

My question is:

I have three huge static arrays defined inside a header file. Someone told me that It's much better to declare them as extern in the header file, and define them in a single C or C++ source file.

How can I do that?

Here is my header file:

#ifndef _TEMPLE_OBJECT_H_
#define _TEMPLE_OBJECT_H_


#define NUM_TEMPLE_OBJECT_VERTEX 10818

static const float TEMPLEVertices[NUM_TEMPLE_OBJECT_VERTEX * 3] = {...};
static const float TEMPLENormals[NUM_TEMPLE_OBJECT_VERTEX * 3] = {...};
static const float TEMPLETexCoords[NUM_TEMPLE_OBJECT_VERTEX * 3] = {...};

#endif

If a use a C++ source file, may I need to define a class?

Thank you.

© Stack Overflow or respective owner

Related posts about c++

Related posts about c