eliemichel / LearnWebGPU-Code

The accompanying code of the Learn WebGPU C++ programming guide
https://eliemichel.github.io/LearnWebGPU
MIT License
114 stars 30 forks source link

Can't compile Step030 #52

Closed yeti424 closed 2 months ago

yeti424 commented 2 months ago

Hi,

hope this question is not too stupid, but I can't compile Step030 (and others non-vanilla ones).

Error message:

/Users/peter/Develop/WebGPU/Step032_Test/main.cpp:75: Fehler: call to implicitly-deleted default constructor of 'Application'
/Users/peter/Develop/WebGPU/Step032_Test/main.cpp:75:17: error: call to implicitly-deleted default constructor of 'Application'
    Application app;
                ^
/Users/peter/Develop/WebGPU/Step032_Test/main.cpp:64:18: note: default constructor of 'Application' is implicitly deleted because field 'device' has no default constructor
    wgpu::Device device;
                 ^ 

I'm using clang compiler on a Mac M1 Pro. Let me know if you need more info...

Regards, yeti

hardcore-thinking commented 2 months ago

Hi.

I suppose your wgpu::Device is an attribute of your Application class. If so, give your device a default value (since it's a pointer you can assign nullptr to it). The default constructor needs to be able to initialize the attributes of the class, otherwise either you initialize them yourself by giving them a default value or you use the initialization list of the constructor (eg. Application::Application() : device(nullptr) {}). In your case, you could just assign nullptr to your device.

Best regards, ajvp

yeti424 commented 2 months ago

Hi,

this worked just fine - thanks for the help!

Best Regards, yeti