Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-01

when will the size of an enumerated type change?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis
Type
    TComparisonMode = (cmThisOnly, cmThisAndThat, cmThisOrThat);
TMyClass = class
public
var
    ComparisonMode : TComparisonMode;
end;

I discovered that, the sizeof(ComparisonMode) seem to be different depending on whether the type TComparisonMode is defined in the same unit file or in another unit file.

Is that possible?

I cannot create a simple test file to test it because the problem only  appears in my big project.

Does FPC always produce a 4 byte variable for an enumerated types?

Dennis

Michael Van Canneyt
to Dennis
Dennis wrote 16 lines
Type    TComparisonMode = (cmThisOnly, cmThisAndThat, cmThisOrThat); TMyClass = class public var    ComparisonMode : TComparisonMode; end; I discovered that, the sizeof(ComparisonMode) seem to be different depending on whether the type TComparisonMode is defined in the same unit file or in another unit file. Is that possible?

If the units are compiled using different settings, yes.

Show quoted text 5 lines
I cannot create a simple test file to test it because the problem only  appears in my big project. Does FPC always produce a 4 byte variable for an enumerated types?

No, it depends on the $mode directive and the settings of the packenum directive.

Michael.