The instance in which I've encountered a .r
file is in Object-oriented Programming with ANSI-C, where a .r
file is used as a "representation" of a class -- (if I understand correctly) a way to perform information hiding by keeping the internal representation and to control access to functions of a class in a separate header file.
Only the implementation of the class would refer to the .r
file, and in that respect it could be regarded as a "private header" to the class. The interface externally to the class, a regular .h
header file was used.
As an illustration, a class may be composed of three files:
Circle.h /* Header file with external interfaces, such as methods. */
Circle.r /* Representation file for internal use within the class, such as
structs that define the internal states. */
Circle.c /* Implementation of the Circle class. */
Then, by convention, a program utilizing the Circle
class may include the Circle.h
file as the interface to access the class. Circle.r
is strictly used by the implementation of the Circle
class and not by others, hence, making it a "private header".
The r
file extension is basically a convention that is used, and is not something that is "official" or used all the time. It is used for convenience and to differentiate from regular header files with a h
file extension.