executable libary pattern `Error: only one entry point `main` is allowed`

monkyyy crazymonkyyy at gmail.com
Sat Jul 20 21:39:05 UTC 2024


got the annoying `Error: only one entry point `main` is allowed` 
again, this time I wanted a real fix rather then leaving a 
comment out main, found this pattern:

```d
foo.d
#!rdmd
import bar;

void main(){
	foobar(3);
}
```

```d
bar.d
#!rdmd -version=localmain
void foobar(int i){
     import std;
     i.writeln;
}

version(localmain){
     void main(){
         foobar(7);
}}
```
---
```bash
% ./bar.d
7
% ./foo.d
3
```


More information about the Digitalmars-d mailing list