Questions tagged [freestanding]

A freestanding implementation of C/C++ is an implementation that can work without an operating system and has an implementation-defined set of libraries. Commonly found in embedded development environments.

The C++ standard defines hosted and freestanding implementations as follows (§1.4/7)

Two kinds of implementations are defined: a hosted implementation and a freestanding implementation. For a hosted implementation, this International Standard defines the set of available libraries. A freestanding implementation is one in which execution may take place without the benefit of an operating system, and has an implementation-defined set of libraries that includes certain language-support libraries (§17.6.1.3).

Use this tag to mark C/C++ questions (together with general and and optionally with tags for specific language standards, for example or ) where these constraints may apply.

Also, make sure the question explicitly states which libraries are and are not available (besides the minimal language support headers that are required).

References:

39 questions
59
votes
1 answer

What is -ffreestanding option in gcc?

What is ffreestanding in gcc ? What is it used for ? I came across the following : gcc -ffreestanding -m32 -c kernel.c -o kernel.o and do not understand, what does it mean exactly.
saplingPro
  • 20,769
  • 53
  • 137
  • 195
25
votes
2 answers

How to compile for a freestanding environment with GCC?

The code I'm working on is supposed to be possible to build for both hosted and freestanding environments, providing private implementations for some stdlib functions for the latter case. Can I reliably test this with just GCC on a normal…
Christoffer
  • 12,712
  • 7
  • 37
  • 53
24
votes
4 answers

Is there a meaningful distinction between freestanding and hosted implementations?

The question I have is mostly related to section four, paragraph six. The two forms of conforming implementation are hosted and freestanding. A conforming hosted implementation shall accept any strictly conforming program. As I understand, this…
autistic
  • 1
  • 3
  • 35
  • 80
10
votes
1 answer

C++ freestanding features

What are the features that I can use in c++ freestanding environment? I am developing a little kernel (for my own pleasure) and I know that I can't use the whole stdlib library, but what else ? when I tried to use the new and delete operators it…
Adrien
  • 439
  • 4
  • 15
6
votes
2 answers

Does C++ for Arduino follow the standard?

C++ programs on the Arduino platform do not have a main() function like on other platforms; instead, it must have two functions named setup() and loop(). But according to C++ standard - all C++ programs must have a main() function. So, does such…
christo
  • 381
  • 2
  • 5
6
votes
1 answer

Freestanding GCC and builtin functions

The GCC docs at http://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html say (under -ffreestanding) that a freestanding environment implies -fno-builtin. I might be misunderstanding exactly what a freestanding environment is or how it works, but it…
Baruch
  • 20,590
  • 28
  • 126
  • 201
5
votes
8 answers

1k of Program Space, 64 bytes of RAM. Is 1 wire communication possible?

(If your lazy see bottom for TL;DR) Hello, I am planning to build a new (prototype) project dealing with physical computing. Basically, I have wires. These wires all need to have their voltage read at the same time. More than a few hundred…
Earlz
  • 62,085
  • 98
  • 303
  • 499
4
votes
1 answer

What are the differences between the various WG14 C standards for freestanding implementations?

How would compilers implementing the freestanding portion of each different standard below have to differ? What would be the fewest number of modes (specified by command line flags, for example) required to support all of them? ISO/IEC…
Shea Levy
  • 5,237
  • 3
  • 31
  • 42
4
votes
1 answer

Why do these two pointers that should be the same point to different data?

I'm writing a FAT16 driver in GNU C for a hobby operating system, and I have a structure defined as such: struct directory_entry { uint8_t name[11]; uint8_t attrib; uint8_t name_case; uint8_t created_decimal; uint16_t created_time; …
Benji Dial
  • 131
  • 7
4
votes
1 answer

Does a port of the C library need to be implemented in C?

I'm working on a kernel. One of the tasks in writing a kernel is that a C library must be ported. Some functions such as memcmp, strlen and so on have to be rewritten. Most of the time I see the code written in C, and then wrapped in extern "C".…
user142809
  • 41
  • 1
3
votes
2 answers

How to prevent GCC from inserting memset during link-time optimization?

While developping a bare metal firmware in C for a RV32IM target (RISC-V), I encountered a linking error when LTO is enabled: /home/duranda/riscv/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld:…
DurandA
  • 1,095
  • 1
  • 17
  • 35
3
votes
2 answers

Call assembly procedure from another assembly file?

Just a simple question: Let's say I had the following two assembly programs: 1: add10: add eax, 10 ret ;call add5 from other file 2: add5: add eax, 5 ret ;call add10 from other file Could I call add10 (declared in the first file) from…
Easton
  • 73
  • 1
  • 9
2
votes
1 answer

Disable generation of deleting destructor

I am developing a program for embedded system that will not use dynamic memory allocation. How can I prevent the GCC from producing deleting destructor (the destructor with D0 in its mangled name)? It will be never called. I think that there is even…
jiwopene
  • 3,077
  • 17
  • 30
2
votes
0 answers

Why the printf function is still usable after adding the freestanding option

Generally, I've already read the following articles, checked the "freestanding/hosted" definition in gcc language standard, but not got my doubts resolved…
Shadow
  • 21
  • 1
2
votes
0 answers

Undefined reference to main() due to signature mismatch when compiling using Clang-6.0 with -ffreestanding

I'm developing an OS kernel as a hobby and I already have a library that replaces the standard library in both hosted and freestanding environments. Naturally it provides the entry point that does the necessary set up and calls main(). In hosted…
r3mus n0x
  • 5,954
  • 1
  • 13
  • 34
1
2 3