AnsweredAssumed Answered

using sizeof() on externs

Question asked by ROB LUND on Apr 18, 2008
Latest reply on Apr 22, 2008 by ROB LUND
Hey guys, here's my setup:

Code:
main.c
#include "main.h"
const Byte array1[] = "sample string";

main.h
#define ARRAY_SIZE sizeof(array1)

file2.c
#include "main.h"
extern const Byte array1[];

for (i=0; i<ARRAY_SIZE; i++)
{
  Function(array1[i]);
}

What I'm getting with this is a C1838 error: Unknown object-size: sizeof (incomplete type).

Yet, if I simply move that array declaration from main.c into file2.c where the array is used, all will compile.  The trouble is, I really need the array with the string to be located inside main.c.

Any ideas what I'm doing wrong?  It's got to be with my extern, right?

Outcomes