This commit is contained in:
Jorijn van der Graaf 2025-11-14 23:56:39 +01:00
commit e3bc669118
7 changed files with 46 additions and 17 deletions

View file

@ -18,7 +18,25 @@ export namespace Catcrafts {
std::string date;
std::string content;
};
std::vector<BlogPost>* posts = new std::vector<BlogPost>{
std::vector<BlogPost> posts {
{
"In WASM, Exit doesn't mean done.",
"in-wasm-exit-doesnt-mean-done",
"2025-11-14",
R"(So if anyone looked at the source code for this website pefore this post you would have seen that every is allocated with new, for example this very blog was defined as <code>std::vector<BlogPost> posts = new std::vector<BlogPost>{...</code><br><br>
Reason for this was that everything became corrupted when callbacking from JS, not knowing sure as to why this was the fastest solution, but after debugging the problem became clear.<br><br>
When we reach the end of <code>int main()</code> from the eyes of C++ we're finished, deconstruct everything and wrap it up. Unkowing that we just registered a bunch of event handlers with JS.<br><br>
This caused all the memory corruption errors since everything was destructed.<br><br>
Luckily this is a very simple fix of adding <code>-fno-c++-static-destructors</code>, and things like this are is also the reason i use clang instead of gcc.<br><br>
So now all examples and this site have been updated to use normal variables again.<br><br>
Stick around for the next post for the <strong>CI/CD nightmare</strong> (not for the faint of heart))"
},
{
"Hello World!",
"hello-world",

View file

@ -11,7 +11,7 @@ import Crafter.CppDOM;
using namespace Crafter;
export namespace Catcrafts {
HtmlElementView* body = new HtmlElementView("body", R"(
HtmlElementPtr body("body", R"(
<header>
<div class="nav-container">
<a href="/" class="logo">🐱 Catcrafts</a>
@ -36,12 +36,13 @@ export namespace Catcrafts {
</div>
</footer>)");
HtmlElementView* head = new HtmlElementView("head", R"(
HtmlElementPtr head("head", R"(
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Catcrafts.net</title>
<link rel="stylesheet" href="/styles.css">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
)");
HtmlElementView* main = new HtmlElementView("main");
HtmlElementPtr main("main");
}