lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Its because you haven't included system libraries that themselves
other libraries and so on. In the end, if you include stdio.h just to
have a single printf function (for, say, a hello world) you end up
with loads and loads of other stuff stuff.

On 10/18/11, Patrick Mc(avery <patrick@spellingbeewinnars.org> wrote:
> On 11-10-18 05:33 PM, David Goehrig wrote:
>> Yes not only will that work but if you guessed it is a direct string
>> replacement for the entire file you'd be right!
>>
>> Try running most C code through cpp and look at the output. Any
>> non-trivial example will contain half the files in /usr/include on most
>> Linux systems.
>>
>> For fun take a program that includes SDL.h
>>
>>    #include<SDL.h>
>>    int main(int argc, char** argv) { return 0;}
>>
>> On my Mac this generates a C file 13977 lines long via cpp. On my Linux
>> box a measly 4573 lines long.
>>
>> The slightly longer file that adds:
>>
>>    #include<GL/gh.h>
>>
>> Is 7909 lines lines on Linux.
>>
>> Awesome!
> Hi David
>
> I've never used cpp before, so I created these files:
> (cppTest.c)
> int function(int a){
>   // int b; I had to move this to the other file or it wouldn't compile
>    #include "other_file.h"
>    return a + b;
> }
>
> int main(int argc, char* argv[])
> {
> function(8);
>      return 0;
> }
>
> and the other file
> (other_file.h )
> int b = 42 ;
>
> I successfully compiled with:
> gcc cppTest.c other_file.h -o cppTest
>
> I ran cpp cppTest.c and ended up with:
> # 1 "cppTest.c"
> # 1 "<built-in>"
> # 1 "<command-line>"
> # 1 "cppTest.c"
> int function(int a){
>
> # 1 "other_file.h" 1
> int b = 42 ;
> # 4 "cppTest.c" 2
>    return a + b;
> }
>
> int main(int argc, char* argv[])
> {
> function(8);
>
>   return 0;
> }
>
> I don't know much about cpp but I can't see the verbose includes that
> you mentioned. Could you explain your numbers a bit more? or perhaps my
> results?
>
> Thanks
>
>
>
>
>
>
>
>
>

-- 
Sent from my mobile device

NI!