bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.63k stars 104 forks source link

`bflat` happily compiles a program without `Main` method #185

Closed ghost closed 5 months ago

ghost commented 7 months ago

and that program failed to run. Windows said, This app can't run on your PC. It took me several hours before I figured it out. The program was ported from Java, where the main method is named main, and I forgot to change it to Main. This means the program is without a Main method. It's not until I used Mono's mcs that I realized this because it refused to compile the program and gave a very clear error message about missing a Main method.

MichalStrehovsky commented 7 months ago

bflat considers things without Main libraries and that's a feature, not a bug. I'll leave this open because the compiler could generate a warning if there's no UnmanagedCallersOnly methods with an entrypoint (the library is a non-sensical library, but it is a library nonetheless).

This app can't run on your PC - the output should have a .dll extension in this case. One needs to go out of their way to rename the file to get this failure mode.

ghost commented 7 months ago

bflat considers things without Main libraries and that's a feature, not a bug. I'll leave this open because the compiler could generate a warning if there's no UnmanagedCallersOnly methods with an entrypoint (the library is a non-sensical library, but it is a library nonetheless).

This is bflat's weirdness. I will note this. Thank you.

This app can't run on your PC - the output should have a .dll extension in this case. One needs to go out of their way to rename the file to get this failure mode.

Again, this is bflat's weirdness. Only bflat requires me to specify the executable name with extension, otherwise it will output an extension-less file. All other compilers choose the extension for the executable automatically.