If you are just trying to achieve the 'enum hack', you should not have to do that in any recent compiler, as they will support static const member declarations.

class Foo
{
private:
    static const int ARRAY_SIZE = 10;
    int m_arr[ARRAY_SIZE];
};

Otherwise, doing an int cast like Jonathan Wood answered would work to change from a managed enum to an int.

Answer from wkl on Stack Overflow
๐ŸŒ
Hhvm
docs.hhvm.com โ€บ enum
Enum | Hack & HHVM Documentation
Use an enum (enumerated type) to create a set of named, constant, immutable values. In Hack, enums are limited to int or string (as an Arraykey), or other enum values.
๐ŸŒ
Hhvm
docs.hhvm.com โ€บ enum class
Enum Class | Hack & HHVM Documentation
The base type of an enum class can be any type: they are not required to be constant expressions and objects are valid values.
Discussions

Enumeration tools
Enumeration will depend on the situation. nmap will always be your #1 tool. Then GoBuster for websites . For AD? Depends as well but there are a few powershell frameworks . Take notes . Organize that based on the attacking phase or service. More on reddit.com
๐ŸŒ r/hackthebox
12
12
January 22, 2024
arrays - Enum trick in C++/CLI - Stack Overflow
If you are just trying to achieve the 'enum hack', you should not have to do that in any recent compiler, as they will support static const member declarations. More on stackoverflow.com
๐ŸŒ stackoverflow.com
does the enum hack work in C? If so, is it supposed to work in VisualStudio 2003? - Stack Overflow
I hate defines. In the quest of eliminating as many of them as possible from an old code base, I need to rely on the enum-hack for defining structures containing arrays. Unfortunately, I'm not gett... More on stackoverflow.com
๐ŸŒ stackoverflow.com
When are enums not a code smell?
In Python there has historically been a strong tendency to use strings as enums, which combined with Python's generally weak typing, can lead to all sorts of issues ยท I also write a fair bit of Swift at the moment, and in Swift codebases I've found that plenty of use of enums, particularly ... More on news.ycombinator.com
๐ŸŒ news.ycombinator.com
90
30
November 23, 2021
๐ŸŒ
tr ouwens
jqno.nl โ€บ post โ€บ 2015 โ€บ 02 โ€บ 28 โ€บ hacking-java-enums
Hacking Java enums - tr ouwens
February 28, 2015 - The final clone method in Enum ensures that enum constants can never be cloned, and the special treatment by the serialization mechanism ensures that duplicate instances are never created as a result of deserialization.
๐ŸŒ
Reddit
reddit.com โ€บ r/hackthebox โ€บ enumeration tools
r/hackthebox on Reddit: Enumeration tools
January 22, 2024 -

Iโ€™m struggling a little. Linking from one tool to another. I understand how to use the tools and in isolation they are ok, however enumerating from one to another with a logical process seems to throw me. Iโ€™m struggling to connect the dots between different scans and how it might lead me to exploit the box.

Is there a process, a list of tools to work through that people could point me in the right direction of. What process do you like to follow. I always start with nmap but then get lost when it comes to following up the open ports. Iโ€™m unaware of which one to pursue and go into a rabbit whole.

If you can advise the best list of tools to use would be greatly appreciated thank.

๐ŸŒ
Javaspecialists
javaspecialists.eu โ€บ archive โ€บ Issue272-Hacking-Enums-Revisited.html
[JavaSpecialists 272] - Hacking Enums Revisited
In a previous newsletter, we looked at how we could dynamically add new enums and also rewire affected switch statements. Due to improvements in Java security, our old approach needs to be updated for Java 12.
Top answer
1 of 2
6

Given the code in the question, GCC warns: warning: declaration does not declare anything for the enum line.

Place the enum outside the struct and you'll be fine.

typedef int P_O_U;
typedef unsigned long ULONG;
typedef unsigned short USHORT;

enum { MAXELEMENTS = 10 };

typedef struct _P_O
{
    P_O_U  elem;
    ULONG  id[MAXELEMENTS];
    USHORT nid;
} P_O, *PP_O;
2 of 2
3
struct foo {
    enum { MAXELEMENTS=10 };
    long id[MAXELEMENTS];
};

enum hack like this is valid in C (But not a good style of code, see @Jonathan Leffler's comment). Because when id is defined, MAXELEMENTS qualifies with enumeration constant.

C99 6.2.1 Scopes of identifiers

Structure, union, and enumeration tags have scope that begins just after the appearance of the tag in a type specifier that declares the tag. Each enumeration constant has scope that begins just after the appearance of its defining enumerator in an enumerator list. Any other identifier has scope that begins just after the completion of its declarator.

And an enumeration is a type of integer constant.

C99 6.6 Constant expressions

An integer constant expression shall have integer type and shall only have operands that are integer constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, and floating constants that are the immediate operands of casts. Cast operators in an integer constant expression shall only convert arithmetic types to integer types, except as part of an operand to the sizeof operator.

Finally, an integer constant can be used in array declarators, see C99 6.7.5.2 Array declarators .That's not surprising.

Find elsewhere
๐ŸŒ
Hacking with Swift
hackingwithswift.com โ€บ read โ€บ 0 โ€บ 14 โ€บ enumerations
Enumerations - a free Hacking with Swift tutorial
September 29, 2025 - Take a look at the first three lines: line 1 gives our type a name, WeatherType. This is what you'll use in place of String or Int in your code. Line 2 defines the five possible cases our enum can be, as I already outlined.
๐ŸŒ
EC-Council
eccouncil.org โ€บ home โ€บ cybersecurity exchange โ€บ ethical hacking โ€บ what is enumeration in ethical hacking?
What is Enumeration in Ethical Hacking and Cyber security?
March 11, 2026 - Enumeration is extracting a systemโ€™s valid usernames, machine names, share names, directory names, and other information. It is a key component of ethical hacking and penetration testing, as it can provide attackers with a wealth of information that can be used to exploit vulnerabilities.
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
When are enums not a code smell? | Hacker News
November 23, 2021 - In Python there has historically been a strong tendency to use strings as enums, which combined with Python's generally weak typing, can lead to all sorts of issues ยท I also write a fair bit of Swift at the moment, and in Swift codebases I've found that plenty of use of enums, particularly ...
๐ŸŒ
Medium
medium.com โ€บ @mikeabelar โ€บ web-development-with-hhvm-and-hack-11-enums-2653782bf5d9
Web Development With HHVM and Hack 11: Enums | by Mike Abelar | Medium
April 7, 2020 - The value of an enum can be accessed by the name of the enum followed by the name of the particular choice of the enum. So Direction::North we will return 1. Then, put the code after the case statement.
๐ŸŒ
Javaspecialists
javaspecialists.eu โ€บ archive โ€บ Issue141-Hacking-Enums.html
[JavaSpecialists 141] - Hacking Enums
We start by writing a test case that should always fail if ever we were able to create an enum (seeing that we cannot create instances of enums): ... We then write a WordFactory that returns word instances. We will change this later to return the hacked enum (and thereby break the test):
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
> We use enums heavily to force devs who use our code into good choices Beware, ... | Hacker News
February 4, 2022 - Beware, tho, that with many languages today youโ€™re not really doing that even when they advertise enums e.g. in both C# and C++, enums are not type-safe (not even `enum class`). Iota is, at least, a fair acknowledgement of that ยท That seems like way a step too far, is there any such โ€œdefault ...
๐ŸŒ
Hhvm
docs.hhvm.com โ€บ introduction
Introduction | Hack & HHVM Documentation
While the contexts shown above are fixed, Hack also supports dependent contexts where a function's context is determined by its arguments or by class constants.
๐ŸŒ
Yjdoc2
yjdoc2.github.io โ€บ 8086-emulator-web
8086 Online Emulator
8086 Online Emulator. Platform Independent. Write, Compile and Execute 8086 Programs Online for Free. Single Step Execution Supported. An Open Source Project.
๐ŸŒ
ZoomEye
zoomeye.ai
ZoomEye Search Engine for Internet Asset Discovery
ZoomEye Black Friday Lifetime Deals โ€” one-time payment for permanent access to our cybersecurity search engine for internet asset discovery, OSINT, and threat intelligence.
๐ŸŒ
MITRE
cwe.mitre.org
CWE - Common Weakness Enumeration
Common Weakness Enumeration (CWE) is a list of software and hardware weaknesses.
๐ŸŒ
Hackage
hackage.haskell.org โ€บ package โ€บ generic-enumeration
generic-enumeration: Generically derived enumerations.
generic-enumeration-0.1.0.5.tar.gz ... information ยท Candidates ยท 0.1.0.0 ยท [back to package description] This is a library that provides generics-based enumeration of all possible values for a type....