curimit / SugarCpp

SugarCpp is a language which can compile to C++11.
135 stars 13 forks source link

static function should not appear in header file #20

Closed zxytim closed 11 years ago

zxytim commented 11 years ago

x.sc

[static]
void func()
    printf("hello world!\n")

instead of compiling to

x.h

#pragma once

static void func();

x.cpp

#include "x.h"

void func() {
    printf("hello world!\n");
} 

it should compile to x.h

#pragma once

x.cpp

#include "x.h"

static void func() {
    printf("hello world!\n");
} 
curimit commented 11 years ago

Thank you, this bug has been fixed.

[static]
void func()
    printf("hello world!\n")

[static]
x: int = 0

class Test
    [static]
    x: int

    [static]
    void func()
        printf("hello world!\n")

test.h

#pragma once

class Test {
    static int x;

    static void func();
};

test.cpp

#include "test.h"

static void func() {
    printf("hello world!\n");
}

static int x = 0;

void Test::func() {
    printf("hello world!\n");
}