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

Error: the crt_destructor pragma is only allowed on function declarations #2599

Closed
bitraft opened this issue Feb 26, 2018 · 1 comment
Closed

Comments

@bitraft
Copy link

bitraft commented Feb 26, 2018

This code working for DMD.

struct Test {
       pragma(crt_constructor) extern(C) static void demo(){
        }
    pragma(crt_destructor) extern(C) static void demo2(){
        }
}

extern(C) void main(){

}
ldmd2 -betterC ./test.d 
Error: the crt_constructor pragma is only allowed on function declarations
Error: the crt_destructor pragma is only allowed on function declarations
@kinke
Copy link
Member

kinke commented Feb 26, 2018

Thanks for reporting. Workaround: put extern(C) before the pragma.

kinke added a commit to kinke/ldc that referenced this issue Jan 6, 2019
E.g., this makes an intermediate `extern(C)` work for functions
(issue ldc-developers#2599, also tested by runnable/test17868b.d).
@kinke kinke closed this as completed Jan 20, 2019
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

2 participants