flat assembler
Message board for the users of flat assembler.
Index
> Windows > The best start to a Windows program Goto page Previous 1, 2 |
Author |
|
fasmnewbie 08 May 2018, 19:41
Furs wrote:
It works either way. From C to binary, main should be the startup function. OTOH, if you're approaching C from the bottom up, C expects similar startup structure, if you're producing an executable. "main" as the startup function is defined in C99 Specification: Code: 5.1.2.2.1 Program startup The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters: int main(void) { /* ... */ } It is also defined in C++98 Standard Code: 3.6.1 Main function [basic.start.main] 1 A program shall contain a global function called main, which is the designated start of the program. [...] 2 An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation defined. All implementations shall allow both of the following definitions of main: int main() { /* ... */ } and int main(int argc, char* argv[]) { /* ... */ } So in hosted environment, as in Windows and Linux, main is a special function assuming these special feature; 1. Global 2. Non-reentrant 3. Not overloaded 4. Should be able to take arguments (from the command lines) 5. Static, as in case of JAVA My low-level examples here will not work without main as the startup module for both Linux and Windows. Or at least I have to go through non-conventional techniques (re-naming the startup point etc) to produce similar result. If you're using C in a freestanding environment, then you are free to come up with your own startup function. |
|||
08 May 2018, 19:41 |
|
Melissa 09 May 2018, 02:50
I think that in C, main can be recursively called, while in C++ cannot. Can't remember exactly.
|
|||
09 May 2018, 02:50 |
|
revolution 09 May 2018, 02:53
Melissa wrote: I think that in C, main can be recursively called ... Code: main(t,_,a) char *a; {return!0<t?t<3?main(-79,-13,a+main(-87,1-_, main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a )&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_, t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\ ,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\ +k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\ l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\ n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \ ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\ #'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/") :t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\ +1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \ i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);} |
|||
09 May 2018, 02:53 |
|
Melissa 09 May 2018, 03:03
Beautiful This is art!
|
|||
09 May 2018, 03:03 |
|
fasmnewbie 09 May 2018, 07:12
revolution wrote:
I guess thats what makes C a powerful language then. Everybody seems to be able to break anything out of it. |
|||
09 May 2018, 07:12 |
|
rugxulo 09 May 2018, 07:50
C was intentionally parsimonious. Most of the dirty tricks usually come from the preprocessor. This particular excerpt is probably some IOCCC winner from years past. EDIT: Seems sources to latest 2018 IOCCC winners were just published a few days ago.
|
|||
09 May 2018, 07:50 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.