Debian c header file location




















In the simplest theoretical case, you have a single source file and a single header file, both in the same directory. In this case, GCC's job seems easy; it just looks in the current directory, finds the header file, and compiles. But actually, there's even a bit of a twist here.

This complexity arises because the behavior differs when you use quotes vs. If you use quotes, the current directory is searched first. If the header file isn't found, then the angle-bracket search path is used. You can verify this by actually "overriding" stdio. I also got a compiler warning about an incompatible implicit declaration of built-in function 'printf' — my new stdio.

So, if a header file is not found in the current directory, where does it look? Surely there must be a way to get GCC to tell you exactly where it's going to end up looking for its header files?

Well, although it's convenient to think of GCC as a single monolithic application that takes in source code files and spits out working programs, it's technically a collection of other programs which chain together to produce the final compiled object file.

The first of these is CPP , short for C Pre-Processor , whose job is to look for compiler directives like include and modify the source code as specified by them; in the case of include, by copying the contents of another file into the current one. This behavior is important — notice the include-fixed directory in the search path? On my system, it includes two files: limits. There are a couple of ways you can manipulate this directory structure. The simplest is by providing the compiler flag -I.

Thus, if you create a directory headers , copy the "overridden" stdio. If you want to add multiple directories to the search path, you specify the -I directory multiples times.

These new directories are added to the beginning of the search path, in the order that they're presented on the command line. In general, though, you should probably never use the CPATH environment variable, since you'll end up creating non-portable source code; specify a Makefile instead.

If you look at all of the CPP search directory examples here, you'll notice that they always start with: include " As we know from experimentation, however, this search does include the current directory; GCC actually does allow you to modify this search path as well, with the -iquote compiler flag.

Here's an edge case that bit me last week. Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search. Where does debian stores C header files like stdio. I am working on a project and I need to add a header file to the location but I couldn't locate it anywhere. But you only should put headers there if you are writing a library which other projects will use. Otherwise, you should use the -I flag for your compiler to specify the location of additional header file search paths.

It wouldn't hurt to run a command like this to make sure you've got the "basics" like compiler and standard headers: apt-get install build-essential. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Location of C header files in debian Ask Question. Asked 9 years, 6 months ago. Imported Layers Copy Created with Sketch. Terms of Use Privacy Policy. Name Required First Last. Email Required. Company Required. Request a Quote. Temperature Range. Target Production Date. Additional Comments. This field is for validation purposes and should be left unchanged. Sign Up. Join Now.



0コメント

  • 1000 / 1000