D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22961 - importC: K&R-style main function rejected
Summary: importC: K&R-style main function rejected
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: ImportC, pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2022-03-29 22:40 UTC by duser
Modified: 2022-03-30 23:06 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description duser 2022-03-29 22:40:33 UTC
int main(argc, argv)
	int argc;
	char **argv;
{ 
	return 0;
}

test.c(4): Error: function `test.main` parameters must match one of the following signatures
test.c(4):        `main()`
test.c(4):        `main(int argc, char** argv)`
test.c(4):        `main(int argc, char** argv, char** environ)` [POSIX extension]

this used to work before the error was added in https://github.com/dlang/dmd/pull/13749
Comment 1 Dlang Bot 2022-03-30 10:28:21 UTC
@MoonlightSentinel created dlang/dmd pull request #13927 "Fix 22961 - Don't reject valid K&R main's in C files" fixing this issue:

- Fix 22961 - Don't reject valid K&R main's in C files
  
  K&R functions are implicitly variadic and hence triggered the error
  if the declaration actually specified parameters (even if when their
  types are correct).
  
  This patch changes the check s.t. it allows implicitly variadic K&R
  functions in C files but still reports an error for explicit `...`.

https://github.com/dlang/dmd/pull/13927
Comment 3 Dlang Bot 2022-03-30 23:06:11 UTC
dlang/dmd pull request #13927 "Fix 22961 - Don't reject valid K&R main's in C files" was merged into master:

- 9c367327d706b1ba4708b395f97a37bd4ab22d3b by MoonlightSentinel:
  Fix 22961 - Don't reject valid K&R main's in C files
  
  K&R functions are implicitly variadic and hence triggered the error
  if the declaration actually specified parameters (even if when their
  types are correct).
  
  This patch changes the check s.t. it allows implicitly variadic K&R
  functions in C files but still reports an error for explicit `...`.

https://github.com/dlang/dmd/pull/13927