When using the Visual Studio 2013 C ++ compiler, I noticed that my code based on size_t was compiled correctly even without including the headers that defined it (i.e. #include <stddef.h>or #include <string.h>).
I tested this because I kind of got the idea of not including the whole title just for something trivial; I feel like this is inflating my code. I came to the conclusion that the C ++ Visual Studio 2013 compiler automatically detects size_t, even without any header inclusions in the code.
While I enjoyed it, I began to worry about portability. Convenience coding and the feeling that my code is elegant is more important to me than absolute mobility; but I would still like mobility. For example, I do not mind using it #pragma once, since most compilers support it, and protecting headers is a problem (especially in Visual Studio), but I would never resort to exporting templates just because one compiler supports it.
So my question is, is automatic size_t detection a widespread feature offered by many compilers, or is it something specific to the Microsoft compiler?
source
share