Reputation: 111
I'm kind of a beginner in c, and I would like to know if there's a way of making a package like in python, for example:
.
├── main.py
└── pkg
├── file1.py
├── file2.py
└── __init__.py
how would that look in c?
I'd imagine something like:
.
├── main.c
└── pkg
├── a.c
├── a.h
├── b.c
└── b.h
is it the way? if so how would that work? how would I use the stuff inside it?
Upvotes: 0
Views: 91
Reputation: 81
As LittleFox explained, there is no 1:1 translation of a package into C. Of course you can write a module in C importing other modules (written in C or not) and provide something that feels like a package.
You can import os and it will provide os.path for you and you can import os.path on your own. Looks like a package? Yes. Is it a package? No. The same you can do from C.
Upvotes: 0
Reputation: 327
There is nothing like this exact thing in C, it does not care about packages.
When you want to distribute a "package" you can build it as library, delivering the header files and precompiled libraries (static or dynamic, per OS and architecture, sometimes per compiler)
If you want to organize a big project into packages, just go ahead like your layout - your tools won't really care. You'd include headers of such "packages" by relative path from where you use it. Compilation depends on your toolchain, but generally you have one big project with all the sources.
Upvotes: 0