Reputation: 3890
I am compiling frmts/gtiff/libtiff/tif_dirinfo.c file from GDAL using android ndk and g++. The tiffFieldArray is defined as a static variable at beginning.
static TIFFFieldArray tiffFieldArray;
Then I use it in the same file:
tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), tiffFields };
But got error:
../../frmts/gtiff/libtiff/tif_dirinfo.c:264:1: error: 'tiffFieldArray' does not name a type
Why?
In tif_dir.h, the struct definition:
#if defined(__cplusplus)
extern "C" {
#endif
...
struct _TIFFFieldArray {
TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */
uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */
uint32 count; /* number of elements in fields array */
TIFFField* fields; /* actual field info */
};
...
#if defined(__cplusplus)
}
#endif
Upvotes: 0
Views: 259
Reputation: 6985
You cannot assign a variable from an initializer list:
tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), tiffFields };
this syntax works only in variable definitions, not assignments. Substitute that line with:
tiffFieldArray[0] = tfiatImage;
tiffFieldArray[1] = 0;
tiffFieldArray[2] = TIFFArrayCount(tiffFields);
tiffFieldArray[3] = tiffFields;
EDIT (after mor info was added in the question)
tiffFieldArray
has a misleading name, since it is a structure, not an array. Anyway the previous solution I posted cannot work in this case. Try writing:
tiffFieldArray.type = tfiatImage;
tiffFieldArray.allocated_size = 0;
tiffFieldArray.count = TIFFArrayCount(tiffFields);
tiffFieldArray.fields = tiffFields;
Upvotes: 1