slint/api/cpp/tests/multiple-includes
Olivier Goffart 2f2116686f C++: forward declare explicitly to make the code more robust
We currently forward declare classes as we use them in functions.
But this breaks if classes with the same name were declared in the
parent namespace. As shown with this example

```C++
// Uncomment that line to make the code break
//struct SharedGlobals;

namespace ns {
    // Is that a forward declaration in `ns`?
    // Depends if it was declared before in the parent namespace
    void foo(struct SharedGlobals *x) {}

    // Actualy define ns::SharedGlobal
    struct SharedGlobals { int x; };

    int xyz() {
        SharedGlobals globals;
        foo(&globals);
    }
}
```

So make sure we forward-declare the classes properly to be more robust
and be able to include generated file with namespace after a file
without namespace

CC #2909
2025-05-26 18:32:09 +02:00
..
another-window.slint C++: forward declare explicitly to make the code more robust 2025-05-26 18:32:09 +02:00
app-window.slint Fixed kebab casing of previous appwindow.slint. 2024-09-20 10:26:49 +02:00
CMakeLists.txt C++: forward declare explicitly to make the code more robust 2025-05-26 18:32:09 +02:00
logic.cpp Fixed kebab casing of previous appwindow.slint. 2024-09-20 10:26:49 +02:00
logic.h Simplify commercial license (#3063) 2024-05-31 14:06:17 +02:00
main.cpp C++: forward declare explicitly to make the code more robust 2025-05-26 18:32:09 +02:00
README.md C++: forward declare explicitly to make the code more robust 2025-05-26 18:32:09 +02:00

This is a test making sure that the header can be included in several compilation without causing multiple definitions

And also that we can include two different generated headers generated different namespaces in the same compilation unit