From 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 14 Aug 2025 22:58:58 -0500 Subject: removing all downloaded devdocs files --- devdocs/c/language%2Fscalar_initialization.html | 50 ------------------------- 1 file changed, 50 deletions(-) delete mode 100644 devdocs/c/language%2Fscalar_initialization.html (limited to 'devdocs/c/language%2Fscalar_initialization.html') diff --git a/devdocs/c/language%2Fscalar_initialization.html b/devdocs/c/language%2Fscalar_initialization.html deleted file mode 100644 index d0fd3411..00000000 --- a/devdocs/c/language%2Fscalar_initialization.html +++ /dev/null @@ -1,50 +0,0 @@ -

Scalar initialization

When initializing an object of scalar type, the initializer must be a single expression

-

The initializer for a scalar (an object of integer type including booleans and enumerated types, floating type including complex and imaginary, and pointer type including pointer to function) must be a single expression, optionally enclosed in braces, or an empty initializer(since C23):

- - - - -
= expression (1)
= { expression } (2)
= { } (3) (since C23)
-1,2) The expression is evaluated, and its value, after conversion as if by assignment to the type of the object, becomes the initial value of the object being initialized.
-3) The object is empty-initialized, i.e. initialized to numeric zero for an object of an arithmetic or enumeration type, or null pointer value for an object of a pointer type.

Notes

Because of the rules that apply to conversions as if by assignment, const and volatile qualifiers on the declared type are ignored when determining which type to convert the expression to.

-

See initialization for the rules that apply when no initializer is used.

-

As with all other initializations, expression must be a constant expression when initializing objects of static or thread-local storage duration.

-

The expression cannot be a comma operator (unless parenthesized) because the comma at the top level would be interpreted as the beginning of the next declarator.

-

When initializing objects of floating-point type, all computations for the objects with automatic storage duration are done as-if at execution time and are affected by the current rounding; floating-point errors are reported as specified in math_errhandling. For objects of static and thread-local storage duration, computations are done as-if at compile time, and no exceptions are raised:

-
void f(void)
-{
-#pragma STDC FENV_ACCESS ON
-    static float v = 1.1e75; // does not raise exceptions: static init
- 
-    float u[] = { 1.1e75 }; // raises FE_INEXACT
-    float w = 1.1e75;       // raises FE_INEXACT
- 
-    double x = 1.1e75; // may raise FE_INEXACT (depends on FLT_EVAL_METHOD)
-    float y = 1.1e75f; // may raise FE_INEXACT (depends on FLT_EVAL_METHOD)
- 
-    long double z = 1.1e75; // does not raise exceptions (conversion is exact)
-}

Example

#include <stdbool.h>
-int main(void)
-{
-    bool b = true;
-    const double d = 3.14;
-    int k = 3.15; // conversion from double to int
-    int n = {12}, // optional braces
-       *p = &n,   // non-constant expression OK for automatic variable
-       (*fp)(void) = main;
-    enum {RED, BLUE} e = RED; // enumerations are scalar types as well
-}

References

-

- © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
- https://en.cppreference.com/w/c/language/scalar_initialization -

-
-- cgit v1.2.3