diff --git a/cmd/wuffs-c/internal/cgen/base/base-public.h b/cmd/wuffs-c/internal/cgen/base/base-public.h index 03287af5..3b10b7c9 100644 --- a/cmd/wuffs-c/internal/cgen/base/base-public.h +++ b/cmd/wuffs-c/internal/cgen/base/base-public.h @@ -56,11 +56,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index cd4dea39..7b064552 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -19,7 +19,8 @@ package cgen const basePublicH = "" + "#ifndef WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n#define WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n\n// Copyright 2017 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n#include \n#include \n#include \n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#ifdef __WORDSIZE\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size " + "of either 32 or 64 bits\"\n#endif\n#endif\n\n// WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/,\n// as a uint64_t. The major number is the high 32 bits. The minor number is the\n// middle 16 bits. The patch number is the low 16 bits. The version extension\n// (such as \"\", \"beta\" or \"rc.1\") is part of the string representation (such as\n// \"1.2.3-beta\") but not the uint64_t representation.\n//\n// All three of major, minor and patch being zero means that this is a\n// work-in-progress version, not a release version, and has no backwards or\n// forwards compatibility guarantees.\n//\n// !! Some code generation programs can override WUFFS_VERSION.\n#define WUFFS_VERSION ((uint64_t)0)\n#define WUFFS_VERSION_MAJOR ((uint64_t)0)\n#define WUFFS_VERSION_MINOR ((uint64_t)0)\n#define WUFFS_VERSION_PATCH ((uint64_t)0)\n#define WUFFS_VERSION_EXTENSION \"\"\n#define WUFFS_VERSION_STRING \"0.0.0\"\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, y" + - "ou can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n} wuffs_base__utility;\n\n" + + "ou can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // c" + + "ompilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" + "" + "// --------\n\n// A status code is either zero (OK), positive (a recoverable suspension or\n// pause in processing) or negative (a non-recoverable error). Its bits:\n// - bit 31 (the sign bit) indicates unrecoverable-ness: an error.\n// - bits 30 .. 24 are a package-namespaced numeric code\n// - bits 23 .. 21 are reserved.\n// - bits 20 .. 0 are the packageid (a namespace) as a base38 value.\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__status__is_error instead.\ntypedef int32_t wuffs_base__status;\n\n// !! INSERT wuffs_base__status names.\n\nstatic inline bool wuffs_base__status__is_error(wuffs_base__status s) {\n return s < 0;\n}\n\nstatic inline bool wuffs_base__status__is_ok(wuffs_base__status s) {\n return s == 0;\n}\n\nstatic inline bool wuffs_base__status__is_suspension(wuffs_base__status s) {\n return s > 0;\n}\n\nconst char* wuffs_base__status__string(wuffs_base__status s);\n\n" + "" + diff --git a/gen/c/base.c b/gen/c/base.c index ad3dfa02..32be2ea0 100644 --- a/gen/c/base.c +++ b/gen/c/base.c @@ -70,11 +70,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index f9016d38..5c11a706 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index 2d967ee2..b04901ee 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index 64aebe05..0d26ace2 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 7e7f00f7..4bea40a7 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index e7182ac8..8b8866d9 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/c/std/lzw.c b/gen/c/std/lzw.c index 922314bf..611b39c7 100644 --- a/gen/c/std/lzw.c +++ b/gen/c/std/lzw.c @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 621efd79..42e00cad 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index 1a9b850d..eaf0778c 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index 44df2678..64c89161 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index 4f9c9cbb..5a947498 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 3fbea65e..2825a46b 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index fab2a792..9cf0a752 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/h/std/lzw.h b/gen/h/std/lzw.h index 5d6214f2..e71e8a68 100644 --- a/gen/h/std/lzw.h +++ b/gen/h/std/lzw.h @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // -------- diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 9820fe08..077f63a6 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -59,11 +59,31 @@ extern "C" { // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__empty_struct; // wuffs_base__utility is a placeholder receiver type. It enables what Java // calls static methods, as opposed to regular methods. typedef struct { + // private_impl is a placeholder field. It isn't explicitly used, except that + // without it, the sizeof a struct with no fields can differ across C/C++ + // compilers, and it is undefined behavior in C99. For example, gcc says that + // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to + // ABI incompatibility if a Wuffs .c file is processed by one compiler and + // its .h file with another compiler. + // + // Instead, we explicitly insert an otherwise unused field, so that the + // sizeof this struct is always 1. + uint8_t private_impl; } wuffs_base__utility; // --------