0

Can we start program without #include..etc

15th Feb 2018, 7:12 PM
rajesh
9 Answers
+ 4
@Martin Taylor, from a practical standpoint you're right. 99.9999
% of the real programs do indeed include some headers. And there's no real point to search a way of avoiding the includes. But still, for you to be able to include some code, it has to be written first. So ultimately, there must be a first header somewhere, that doesn't include anything. Anyway, the question was whether it is possible, and the answer to that is — it is. If the question was whether a programmer ever needs to write a program that includes no headers, the answer to that would be — not likely. This is only probable in cases of developing of some really low level code, but it most likely would be a library, not a program. P.S. Inline assembly example: https://code.sololearn.com/c0he6xZ4u2up/?ref=app
16th Feb 2018, 1:06 AM
deFault
+ 4
One thing I would like to remind though, is that C++ isn't C#, and it's scope is a bit wider than just writing Windows applications. That said, it is possible to write meaningful Unix programs using syscalls directly, which can be done without any includes. And also, it's possible to write embedded programs, that have all the ISRs and port addresses defined in the single program file. Though still, the ISR and port address defines are usually placed in a separate header file, as well as the syscall routines. But that is rather for code structuring and portability reasons.
16th Feb 2018, 4:16 AM
deFault
15th Feb 2018, 11:56 PM
deFault
+ 2
@Dejan Francuz, I know, that it's the most "unusual" example I could come up with, but it still proves the point that it's possible to create a program without any includes. Apart from the trickery like in that code, you may use C-like I/O functions or system syscalls - that doesn't require any includes too. Also a program may be some kind of low-level thing that doesn't need any I/O at all.
16th Feb 2018, 12:06 AM
deFault
0
No you can't. Try it by yourself , delete #include and try to cout or to sum.
15th Feb 2018, 11:48 PM
Dejan FrancuzđŸ„‡
Dejan FrancuzđŸ„‡ - avatar
0
@Marvin , tell me who's programming like that ?
15th Feb 2018, 11:57 PM
Dejan FrancuzđŸ„‡
Dejan FrancuzđŸ„‡ - avatar