Topic : STM8 Compiler and the SUEOPT option

Forum : ST7/STM8

Original Post
Post Information Post
May 4, 2009 - 5:33pm
Guest

Hi guys...
I am using this compiler with something like this :

/* PROTOCOL HEADER */
typedef struct AEP_Header{
long ID; // The device ID
char DataSize; // The Data Size of the whole data going to follow
};

/* VARIOUS ITEMS */

// Standard Reply
typedef struct AEP_Reply{
struct AEP_Header; <<-- 'Invalid declaration syntax' ON THIS LINE
char Reply;
char CheckSum;
};

So, it's a standard template used for an unnamed variable
Now, the compuler gives me error on the marked line, 'Invalid declaration syntax '...
I can suppose I need to declare the SUEOPT option for the compiler to use an unnamed structure, but found no place where to put such an option, even reading the manuals...

1st - In manual it's reported as 'SUEOPT(struct_opt)', what does this means, it's not clear what 'struct_opt' is for...
2nd - Where to place this options, tried with #pragma and got an unknown pragma error, and found no 'RCSTM8 general options' box anywhere in the IDE as told by the manuals...
3rd - Placed in IDE defines too, but always got that such a SUEOPT is unknown...
4th - would this 'unnamed' declaration be accepted by this compiler...?

Tnx

Best regards...

Alex Vallone
Official STM Consultant

Replies
Post Information Post
+1
0
-1
May 5, 2009 - 12:33pm
Raisonance Support Team

Hi Alex,

This is a documentation bug: The shortcut is SUE_OPT, not SUEOPT! We will correct the documentation appropriately.
The full pragma name is "struct_opt" and is correctly documented. You can invoke it through the following first line in your code:
#pragma SUE_OPT

However, it does NOT do what you want: What it does is that it enables you to remove the "struct" keyword, but not to remove the field name (no unnamed fields possible).

So you can write:

#pragma SUE_OPT

/* PROTOCOL HEADER */
typedef struct AEP_Header{
    long       ID;
    char       DataSize;
};

// Standard Reply
typedef struct AEP_Reply{
    AEP_Header foo;
    char       Reply;                        
    char       CheckSum;                    
};

I hope this helps,
Bruno