Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in compiling https://immediate-mode-ui.github.io/Nuklear/doc/#nuklear/example #600

Closed
raphael10-collab opened this issue Dec 28, 2023 · 0 comments

Comments

@raphael10-collab
Copy link

In basic.cc file :

#define NK_IMPLEMENTATION
#include "../../Nuklear/nuklear.h"

// https://immediate-mode-ui.github.io/Nuklear/doc/#nuklear/example

/* init gui state */
struct nk_context ctx;
//nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);

nk_bool nk_init_default(struct nk_context *ctx, const struct nk_user_font *font);

// init gui state
enum {EASY, HARD};
static int op = EASY;
static float value = 0.6f;
static int i =  20;
//nk_init_fixed(... &ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);

nk_bool nk_init_default(struct nk_context *ctx, const struct nk_user_font *font);

if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
    NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
    // fixed widget pixel width
    nk_layout_row_static(&ctx, 30, 80, 1);
    if (nk_button_label(&ctx, "button")) {
        // event handling
    }
    // fixed widget window ratio width
    nk_layout_row_dynamic(&ctx, 30, 2);
    if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
    if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;
    // custom widget pixel width
    nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
    {
        nk_layout_row_push(&ctx, 50);
        nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
        nk_layout_row_push(&ctx, 110);
        nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
    }
    nk_layout_row_end(&ctx);
}
nk_end(ctx);

Compiling:

cmake --build cmakebuilddir/
[ 14%] Building CXX object CMakeFiles/basic.dir/src/basic.cc.o
/home/raphy/webview-prj/src/basic.cc:40:1: error: expected unqualified-id before ‘if’
   40 | if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
      | ^~
/home/raphy/webview-prj/src/basic.cc:61:7: error: expected constructor, destructor, or type conversion before ‘(’ token
   61 | nk_end(ctx);
      |       ^
gmake[2]: *** [CMakeFiles/basic.dir/build.make:76: CMakeFiles/basic.dir/src/basic.cc.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/basic.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant