News for hackers. Stuff that matters.
Re:Show HN: Buckaroo – A decentralized C++ package manager by c-smile on Friday February 01, 2019 @02:53PM (#19057818)
I just want C/C++ to support `include source` statement.

So in order to include some library I'll put

   #include source "libpng/png.c";
in my main.c file. And that png.c may look as:

   #include source "png-a.c"
   #include source "png-b.c"
   #ifdef PNG_FEATURE_C
     #include source "png-b.c"
   #endif
   ...
 
And that would be it.

C/C++ preprocessor is enough for configuration.

Re:Show HN: Buckaroo – A decentralized C++ package manager by MereInterest on Friday February 01, 2019 @02:59PM (#19057882)
Could you verify what you mean by an include source statement? As you describe its usage, it seems identical to the already existing #include statement, which does a text inclusion of another file.
Re:Show HN: Buckaroo – A decentralized C++ package manager by c-smile on Friday February 01, 2019 @03:14PM (#19058036)
#include "path.c"; inserts path.c into current compilation unit.

#include source "path.c"; compiles and includes path.c as a new compilation unit ( https://en.wikipedia.org/wiki/Single_Compilation_Unit ) .

So if a-file.c and b-file.c are both have

    static int foo = 42;
then these two files can be successfully included as

    #include source "a-file.c" 
    #include source "b-file.c"
But this:

    #include "a-file.c" 
    #include "b-file.c"
will produce the error "foo is already defined"

This small feature will allow 99% of existing libraries to be included this way - without any makefile, GUP, GIP and the rest of the zoo.

Now I can put in Microsoft VC++ this

    #pragma comment(lib, "some.lib") 
to include the library into final binary.

#include source is just a generalization of the idea.

Re:Show HN: Buckaroo – A decentralized C++ package manager by jackewiehose on Friday February 01, 2019 @05:54PM (#19059583)
I think what we all want is a proper import-statement.

> as a new compilation unit ( https://en.wikipedia.org/wiki/Single_Compilation_Unit )

> Single Compilation Unit (SCU) is a computer programming technique [...] The technique can be applied to an entire program or to some subset of source files; when applied to an entire program, it is also known as a unity build.

Who came up with that? I would say this "technique" doesn't even justify having a wikipedia page. In modern c++ you can be glad if you have a c++ unit that doesn't need to recompile on change because of all the header-only stuff. No one would include .cpp-files by choice.

Re:Show HN: Buckaroo – A decentralized C++ package manager by fwip on Friday February 01, 2019 @05:07PM (#19059212)
And if b-file.c says "static int foo = 43;" what is the desired behavior?
Re:Show HN: Buckaroo – A decentralized C++ package manager by c-smile on Friday February 01, 2019 @05:28PM (#19059381)
In C/C++ static declarations are local to the compilation unit. So you will have two separate storages for foo - these will be two independent variables.

That's how C and C++ work.

And if you will have this (no static):

    int foo = 45; 
then linker will complain - "multiple 'foo' entities" as non-static entities have global visibility.
Re:Show HN: Buckaroo – A decentralized C++ package manager by ghthor on Friday February 01, 2019 @05:14PM (#19059269)
I'd imagine a compiler error that static values, aka globals, must not differ at compile time. This would likely apply to consts as well.
Re:Show HN: Buckaroo – A decentralized C++ package manager by c-smile on Friday February 01, 2019 @05:30PM (#19059397)
"must not differ at compile time"

not so, static declaration are local for the compilation unit so you may have as many different foo's as files you have in your project.