How do I create a unit with only enums in it?


(Theo) #1

I try to create a unit with only enums in it:

namespace NS;
interface
testEnum = enum(a=0,b=1);
implementation
end.

The enum is not compiled.

But if I add a type to it:

namespace NS;
interface
type x= class end;
testEnum = enum(a=0,b=1);
implementation
end.

Everything works.
How can I make a unit without the type?


(joseasl) #2

Have you tried public enum?


(marc hoffman) #3

you’re missing the type keyword. I’m surprised this first sample compiles at all?


(marc hoffman) #4

ps, it doesn’t here for me. s expected:

namespace NS;
interface
testEnum = enum(a=0,b=1); // E3 "implementation" or interface section members (types or methods) expected
implementation
end.

(Theo) #5

No, the first example does not compile.
That was the problem; I only want enums in this unit, but I have to add a type before I can compile.


(Carlo Kok) #6

Well just the type keyword.
type testenum = enum (a = 0, b = 1); works fine.


(marc hoffman) #7

So thats just as designed then? Pascal needs the type keyword before declaring types… If you omit it, it will fail.


(Theo) #8

yep - as designed.
This was the first time that I tried to make a unit with only enums in it …