What is an .inc and why use it?
It has no meaning, it is just a file extension. It is some people's convention to name files with a .inc extension if that file is designed to be included by other PHP files, but it is only convention.
It does have a possible disadvantage which is that servers normally are not configured to parse .inc files as php, so if the file sits in your web root and your server is configured in the default way, a user could view your php source code in the .inc file by visiting the URL directly.
Its only possible advantage is that it is easy to identify which files are used as includes. Although simply giving them a .php extension and placing them in an includes folder has the same effect without the disadvantage mentioned above.
What's the point of a `.inc` file in C++ & C? What situation would you want to use it?
The extension is just a different one than .h or .hpp. I wasn't there when whoever decided to name the file this way. There is no particular reason other than convention that determine extensions in general.
As Jonathan points out, it may be to distinguish it from "regular header files" that are usable anywhere.
The comment above the inclusion of these files is perhaps a reasonable explanation:
// Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX
#include "Unix/Signals.inc"
#endif
#ifdef LLVM_ON_WIN32
#include "Windows/Signals.inc"
#endif
These contain platform specific parts, it is not, as such, a "header-file", it is just a portion of code that is dependent on the target architecture, and someone decided that it's better to have two separate files than to have a huge #ifdef
in the one source file. [A reasonable decision, in my mind, as the Unix file I looked at is several hundred lines, with further stuff included and some more #if
]
Want some information about .inc files
An inc file is just a file that contains some stuff (functions, classes, constants) that you want to be able to include in other files.
There is no difference between an inc file and a php file, except that unless specifically configured to do so, your server won't execute the php in an inc file unless it is included in a php file.
You can include the file like this:
include "directory/file.inc";
Once you've included the file, you can consider its content to be part of the file you are in, so you can access the contents as you would if they were in your file.
Note: There is no special meaning to the .inc extension - you could call it a .bunnyrabbit file, and it would work exactly the same.
Difference between .h files and .inc files in c
The standard convention is to use .h
for header files that contain only macro definitions and other declarations and .c
for C source files that contain code and data definitions.
In some projects, code fragments are stored in separate files and included in C source files with some macro tricks to expand specifically in different files or circumstances. Sometimes, these files are even included multiple times in the same source file. To underscore the special semantics attached to such files, giving them a different extension may be a useful hint. These files may also have been generated as part of the build process: naming them specifically may prevent confusion with actual source files.
Look at the files you came across in these projects and verify if this explanation holds.
What are *.inc files in LLVM build
You are probably talking about files generated by TableGen utility. This process is slow for you because you've built it in Debug mode, probably. There is a CMake option called LLVM_OPTIMIZED_TABLEGEN
to build TableGen in Release mode regardless the build type of all other projects.
Handle .inc files as PHP
If you are including them via include()
or require()
into your PHP code, there's no need to change the extension. Anything included via the include()
family is already treated as PHP.
Addendum:
Please also see @Darhazer's answer configuring Apache to serve .inc
as PHP if you have a need to do so. (It's not totally clear from your question).
Does vscode editor support .inc file highlight?
.inc
files are used in multiple languages; what language are you using them in?
You can tell VSCode to apply language-specific syntax highlighting by editing the settings.json
(File > Preferences > Settings) by adding the file extension to the highlighting category.
For example, to highlight .inc
files as PHP,
{
"files.associations": { "*.inc": "php"}
}
See this link for more details.
Related Topics
How to Determine the Memory Footprint (Size) of a Variable
PHP Errors Not Being Displayed in the Browser [Ubuntu 10.10]
How to Build Unlimited Level of Menu Through PHP and MySQL
How to Set Up Entity (Doctrine) for Database View in Symfony 2
Php's Preg_Match() and Preg_Match_All() Functions
Multiple Submit Buttons PHP Different Actions
Delete First 3 Characters and Last 3 Characters from String PHP
How to Regex-Replace Multiple <Br /> Tags with One <Br /> Tag
PHP Filesize Reporting Old Size
Xdebug V3 Doesn't Stop Breakpoints in VScode
How to Store an Array into MySQL
In PHP, How to Detect the Execution Is from Cli Mode or Through Browser
Download CSV File Using "Ajax"
Redirecting to Authentication Dialog - "An Error Occurred. Please Try Again Later"
How to Use "Root" Namespace of PHP