Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: da547bc96ada9dcc7fcb9ae80d7df55101715d0ed81ccd8458ef201d9f6e96bc
Ticket: 1e48483c8b3b2702b981ebcc85474512bb3d6e0d
Use of non-standard C code in TCLBOOLWARNING
User & Date: gustafn3 on 2024-05-01 10:19:46
Changes

  1. icomment:
    With the following version of the macro, it compiles clean with and without -std=c99 under Linux (tested with gcc version 12.2.0) and macOS (tested with standard Apple compiler clang-1500.3.9.4 and clang 17.0.6)
    
    #if !defined(__cplusplus) && !defined(BUILD_tcl) && !defined(BUILD_tk) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
    #       define TCLBOOLWARNING(boolPtr) (void)(sizeof(struct {_Static_assert(sizeof(*(boolPtr)) <= sizeof(int), "sizeof(boolPtr) too large");int dummy;})),
    #elif defined(__GNUC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
            /* If this gives: "error: size of array ‘_bool_Var’ is negative", it means that sizeof(*boolPtr)>sizeof(int), which is not allowed */
    #   define TCLBOOLWARNING(boolPtr) ({__attribute__((unused)) char _bool_Var[sizeof(*(boolPtr)) > sizeof(int) ? -1 : 1];}),
    #else
    #   define TCLBOOLWARNING(boolPtr)
    #endif
    
  2. login: "gustafn3"
  3. mimetype: "text/plain"