Thread: ENC: [Dev-C++] Two Questions
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <and...@su...> - 2003-09-15 16:18:12
|
-----Mensagem original----- De: André Macário Barros [mailto:and...@su...] Enviada em: domingo, 14 de setembro de 2003 21:13 Para: Per Westermark Assunto: RES: [Dev-C++] Two Questions I have here one version of K&R, another copy of Deitel´s, some others books and some links that I didn´t find theese answers. Yes, this is one kind of school work. My students did theese questions and I didn´t find on the books the correct answer for both cases. I have a feeling about the probable answers, I can make some practical tests to check this, but this can´t be a answer from a teacher. In this position, I can´t give some answers without the respective bibliography for the student look for more information. If anyone of you can give me theese answers it would be great. Thanks in advance. Andre Barros -----Mensagem original----- De: Per Westermark [mailto:pw...@ia...] Enviada em: domingo, 14 de setembro de 2003 19:52 Para: André Macário Barros Cc: Dev-Cpp-Users Assunto: Re: [Dev-C++] Two Questions Bibliographic references are for school work and are better located by yourself. /Per W On Sun, 14 Sep 2003, André Macário Barros wrote: > Dear Users, > > 1) Does exist any difference in speed with C codes that use > > function prototypes > main function > function definitions > > or > > function definitions > main function > > 2) Does a C code need the entitled "main" function to run alone? Please, > disconsider the WinMain case > > Fellows, if possible, together with the answers, please indicate > bibliography > or link that contains the answers. > > Regards > Andre Barros > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: <ri...@un...> - 2003-09-15 17:04:17
|
question 1): Try to build a program with the 2 possibilities you are proposing and keep the running time in both cases... after that, you could tell us the result... as you say it seems that there wont be any difference, that is, the final binary code is the same in both cases. question 2): the main function is not needed to run, if not essentially to compile the code...without the main function the compiler doesnot know where the nucleus of the program is, then the compiler can not compile... it is the 'door' toward the code...without 'door' you can not go into... hope it helps you, Ricardo. |
|
From: Per W. <pw...@ia...> - 2003-09-15 17:24:21
|
1) Normally, it doesn't matter if the compiler sees just a function prototype or if it sees the complete implementation before you call a function. However, some compilers have a compiler switch that allows the compiler to itself select functions for inlining. Obviously, with only a function prototype it can't inline the function. However, if the code is in the same source file, but after the call, the compiler is probably smart enough to find it anyway, since most compilers doesn't generate any code immediately for release build, but only builds parse trees in memory before performing the different optimization steps. 2) You can compile a program without a main() but you can't link the program. The startup code hidden somewhere inside the run-time-library code does contain a call to a main function. Either you have to supply it, or it must be available in a object or library file included in the linking. For Windows, one of the Windows libraries contains a main(). /Per W On Mon, 15 Sep 2003, Ricardo_L=F3pez-Ruiz wrote: > question 1): > Try to build a program with the 2 possibilities you are proposing > and keep the running time in both cases... after that, you could tell us > the result... > as you say it seems that there wont be any difference, that is, > the final binary code is the same in both cases. > > question 2): the main function is not needed to run, if not essentially > to compile the code...without the main function the compiler doesnot know > where the nucleus of the program is, then the compiler can not compile... > it is the 'door' toward the code...without 'door' you can not go into... > > > hope it helps you, > Ricardo. > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: <and...@su...> - 2003-09-15 19:56:04
|
GREAT... Thank you all!
One last question: inline functions provide more speed. No
doubt about that. But,
Are inline functions allowed in C or only in C++?
Regards
Andre Barros
ps1: regarding the prototype stuff, probably I will make a test with
20 dummy functions been called by the main function and compare
to its "mirror" case (without prototypes).
ps2: very interesting the answer to the main stuff :-)
-----Mensagem original-----
De: Per Westermark [mailto:pw...@ia...]
Enviada em: segunda-feira, 15 de setembro de 2003 14:24
Para: Ricardo_López-Ruiz
Cc: André Macário Barros; Dev-C
Assunto: Re: ENC: [Dev-C++] Two Questions
1) Normally, it doesn't matter if the compiler sees just a function
prototype or if it sees the complete implementation before you call a
function. However, some compilers have a compiler switch that allows the
compiler to itself select functions for inlining. Obviously, with only a
function prototype it can't inline the function. However, if the code is
in the same source file, but after the call, the compiler is probably
smart enough to find it anyway, since most compilers doesn't generate any
code immediately for release build, but only builds parse trees in memory
before performing the different optimization steps.
2) You can compile a program without a main() but you can't link the
program. The startup code hidden somewhere inside the run-time-library
code does contain a call to a main function. Either you have to supply it,
or it must be available in a object or library file included in the
linking. For Windows, one of the Windows libraries contains a main().
/Per W
On Mon, 15 Sep 2003, Ricardo_López-Ruiz wrote:
> question 1):
> Try to build a program with the 2 possibilities you are proposing
> and keep the running time in both cases... after that, you could tell us
> the result...
> as you say it seems that there wont be any difference, that is,
> the final binary code is the same in both cases.
>
> question 2): the main function is not needed to run, if not essentially
> to compile the code...without the main function the compiler doesnot know
> where the nucleus of the program is, then the compiler can not compile...
> it is the 'door' toward the code...without 'door' you can not go into...
>
>
> hope it helps you,
> Ricardo.
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|