How does the compiler know which source file is the one I am including? Does it work as long as the name of the header and source file are the same? For example, the header file example.h refers to example.c and so including example.h would be already enough?
Why only include header files (.h) but not the source file (.c) in the directives?
1k Views Asked by Captain Toad At
1
There are 1 best solutions below
Related Questions in C
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in MODULE
- (in promise) TypeError: NetworkError when attempting to fetch resource
- Cannot load modules/mod_dav_svn.so into server
- Not reading the function in a JavaScript Module file, by calling onclick in the html document
- Adding Modules to a Namespace using IIFE
- Preparing metadata (pyproject.toml) ... error
- I want to understand modularity in java. When compiling my app I have a ResolutionException
- ModuleNotFoundError: No module named 'src' while importing logging
- Nest.js can't resolve dependencies of the external library's Reflector dependency
- Npm build error: "Module not found: Error: Can't resolve './component/intro' in
- problemas con los CORS en .net core 7 y angular 15
- how can i fix this :ModuleNotFoundError
- A given package is installed but spyder won't see it
- Should I even continue trying to import a module from the parent package?
- Linking errors with includes in C++ nested modules
- Export and create package of c++20 modules
Related Questions in HEADER-FILES
- C++ - Unknown type name
- Unable to install old gcc version on Mac using homebrew. Error in make possibly due to incorrect header file version
- External macro definition in header
- How to create your own C++ Library and share it with others so that everyone can use it?
- White space to the right side of my header/navbar
- How C ++ header files hold the cpp respective file definitions if they do not include them on themselves?
- Trying to render texture but I can't pass the variable to draw function
- Question about header files and functions in separate files in C++
- Visual Studio Additional Include Directories
- Initializing a large map in header cause g++ crashes
- Umbrella-Header uses wrong import syntax after `pod install`
- The game module "project name "could not be loaded. There may be an operating system error or module may not be properly setup
- Why does it throws an error while putting functions into header in VSCode but not GCC?
- Why net/if.h before ifaddrs.h?
- Error about the Redefinition of a struct and conflicting types for a function
Related Questions in PREPROCESSOR
- External macro definition in header
- How come clang and gcc don't produce a cast warning for this openssl macro, but do otherwise?
- How to generate/pass unique UUID to Threads independent of each other in JMeter's Stepping Thread Group
- How does the compiler predefine the OS-specific preprocessors like __linux__, __apple__, etc.?
- Can the region be used as a variable?
- Unable to `#define` in Fortran's program body
- Uncrustify C function parameter in the presence of preprocessor directive
- GCC preprocessor macro and "#pragma GCC unroll"
- C macros with states
- Is the format of the preprocessing correct?
- gcc -E generating intermediate files for a c source file but EXCLUDE standard libs with -nostdinc option
- Undefined Macro in #if directive?
- how to crop and straight an EL image of solar panel in Matlab
- How to access GitHub Repository test data file via Jmeter JSR223 PreProcessor script?
- Achieve the opposite of __VA_OPT__ in variadic preprocessor function-like macros
Related Questions in COMPILER-DIRECTIVES
- Compiler Directive to check if Skia is enabled on my Delphi FIreMonkey App?
- GAS (gnu assembler) and conditional execution
- Delphi 11.3 compiler directives for "Development" and "Application store" modes
- What does the {$IFNDEF LCLTMSWEB} compiler directive mean?
- How do I add a compiler directive for TMS Web Core websites?
- Pass by name for macro arguments
- default value for macro declaration
- SwiftUI compiler directives trigger "Cannot infer contextual base" error for following statements
- Visual Studio C# Project Template #if DEBUG #endif disappear in produced projects
- How to assert size of `usize` to drop support for incompatible platforms?
- {$WARN DUPLICATE_CTOR_DTOR OFF} gets deleted from Dpk file
- Why only include header files (.h) but not the source file (.c) in the directives?
- Compiler says variables declared within compiler directive doesnt exist
- How to change a .dfm property with compiler directives?
- Local labels in emu8086
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It doesn’t. The compiler only knows what you tell it. Header files are designed to tell the compiler what exists elsewhere.
It makes no difference. By convention, we humans find it easier to name them the same so that we can correlate example.h and example.c as the header and source for the same module.
It should be enough to tell the compiler what things exist in example.c.
Remember, the header’s purpose is to explain what exists in other source file(s). (And to declare types, which by themselves don’t create code.)
This is a C question, but there is a very good overview at learncpp.com that applies equally to C as it does to C++. Specifically, you may wish to read through: