config.h evil typedef

Create issue
Issue #116 resolved
Joris created an issue

config.h contains the line (48): {{{ #!C typedef struct ConfigHandle *ConfigHandle; }}}

This breaks when compiling a C++ module.

Changing this line to {{{ #!C typedef struct ConfigHandle_ *ConfigHandle; }}}

Solves the issue. config.c must also be updated

Comments (3)

  1. Former user Account Deleted

    Could you elaborate on this a bit? Why is this a problem in C++? What is the fix fixing? Is the fix going to break C?

  2. Joris reporter

    This is the only thing that prevents C++ modules from compiling in a stock asss (rest of asss is still C).

    The reason is that the following is valid C++:

    struct Test { int a; }
    void foo() {
         Test test;
         test.a = 5;

    "struct Test" introduces 2 symbols: "Test" and "struct Test". In C you would accomplish this by doing:

    typedef struct Test Test;

    (When compiling this as C++, the typedef has no effect for backwards compatibility)

    But, when you do something like

    typedef struct Test *Test;

    There's a conflict. There already was a "Test" which is of the type "struct Test", but now you are redefining Test as "struct Test*". This will not compile.

    I have grep'd the asss source code and the only place where the incomplete "struct ConfigHandle" is used instead of the typedef, is in config.c. Everything else uses the typedef "ConfigHandle". The fix could prevent compilation of non default modules that use "struct ConfigHandle*". Compiling will give an error.

  3. Log in to comment