-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
add Windows console omf startup description #3478
Open
WalterBright
wants to merge
1
commit into
dlang:master
Choose a base branch
from
WalterBright:Windows3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,55 @@ $(P This covers Windows programming with 32 bit OMF, 32 bit Mscoff, | |||||
64 bit Mscoff, console programs, GUI programs, and DLLs. | ||||||
) | ||||||
|
||||||
$(H2 All Console Programs) | ||||||
|
||||||
$(P A D console program is specified by having a function with D linkage at module level called `main`. | ||||||
When the compiler sees this, it triggers the mixin template `core.internal.entrypoint._d_cmain` | ||||||
to be added. The `_d_cmain` template looks like: | ||||||
) | ||||||
--- | ||||||
template _d_cmain() | ||||||
{ | ||||||
extern(C) | ||||||
{ | ||||||
int _d_run_main(int argc, char **argv, void* mainFunc); | ||||||
|
||||||
int _Dmain(char[][] args); | ||||||
|
||||||
int main(int argc, char **argv) | ||||||
{ | ||||||
return _d_run_main(argc, argv, &_Dmain); | ||||||
} | ||||||
|
||||||
// Solaris, for unknown reasons, requires both a main() and an _main() | ||||||
version (Solaris) | ||||||
{ | ||||||
int _main(int argc, char** argv) | ||||||
{ | ||||||
return main(argc, argv); | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
--- | ||||||
$(P The `main` function in it, because it is marked as `extern(C)`, is the entry point of a | ||||||
C console program. The executable starts up as a C executable, with the C runtime library | ||||||
initializing and then the C main() function is called.) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
$(P The C runtime library will runs any D functions tagged with `pragma(crt_constructor)` as | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
part of its initialization, and before it calls C `main()`. The order in which these | ||||||
are run is not specified.) | ||||||
$(P The C `main` function then calls the D runtime library function `_d_run_main`, passing it | ||||||
`argc` and `argv`, and the address of `_Dmain`. The compiler renames the D `main` function in | ||||||
the source code to `_Dmain`.) | ||||||
$(P `_d_run_main` then initializes the D runtime library, converts `argc` and `argv` to `args`, | ||||||
and calls the D `main` function.) | ||||||
$(P When the D `main` function returns, control is back in `_d_run_main` which shuts down the | ||||||
D runtime library, and then returns to the C `main`, which then returns to the C library | ||||||
which shuts down the C runtime library, then exits the program.) | ||||||
$(P The C runtime library runs any D functions tagged with `pragma(crt_destructor)` as | ||||||
part of its shutdown, in the reverse order that the `pragma(crt_constructor)`s were run. | ||||||
) | ||||||
|
||||||
$(H2 $(LNAME2 mscoff, Windows 32 and 64 bit MSCOFF Programs)) | ||||||
|
||||||
$(P 32 bit and 64 bit MSCOFF programs use the Microsoft Visual C/C++ compiler as the Associated | ||||||
|
@@ -30,8 +79,19 @@ $(H2 $(LNAME2 omf, Windows 32 bit OMF Programs)) | |||||
to link them. | ||||||
) | ||||||
|
||||||
|
||||||
$(H3 $(LNAME2 omf-console, Console Programs)) | ||||||
|
||||||
$(P The existence of a C `main` function causes the compiler to insert in the object file:) | ||||||
|
||||||
$(UL | ||||||
$(LI a directive in the object file which tells $(TT Optlink) to search the Digital Mars C runtime library $(TT snn.lib) | ||||||
to resolve any undefined symbols) | ||||||
$(LI 2. a reference to $(TT __acrtused_con) which appears in the C runtime library, causing $(TT Optlink) | ||||||
to pull in the C runtime library code) | ||||||
) | ||||||
|
||||||
|
||||||
$(H3 $(LNAME2 omf-windows, Windows GUI Programs)) | ||||||
|
||||||
$(H3 $(LNAME2 omf-dlls, DLLs)) | ||||||
|
@@ -43,4 +103,3 @@ Macros: | |||||
CHAPTER=43 | ||||||
TITLE=Windows Programming | ||||||
CATEGORY_SPEC=$0 | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has anyone tried asking Solaris?