GCC with -m16 flag does not compile

  16-bit, c++, gcc, linux

I am using a Debian OS:

[email protected]:~$ uname -a
Linux clunasvm 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux

And GCC:

[email protected]:~$ gcc --version
gcc (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I have a Hello World C++ application that I would like to compile with -m16 flag to generate 16 bit code. When I add the flag to the compiler, the code does not compile:

g++ -O0 -g3 -Wall -c -fmessage-length=0 -m16 -MMD -MP -MF"src/test.d" -MT"src/test.o" -o "src/test.o" "../src/test.cpp"
In file included from /usr/include/features.h:448,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/c++config.h:508,
                 from /usr/include/c++/8/iostream:38,
                 from ../src/test.cpp:9:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: gnu/stubs-32.h: No such file or directory
 # include <gnu/stubs-32.h>
           ^~~~~~~~~~~~~~~~
compilation terminated.

What else am I missing to be able to produce a 16 bit based code on an x86-64 machine? The reason why I need this is to simulate a 16 bit CPU behavior in code.

Source: Windows Questions C++

LEAVE A COMMENT