Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tend to think like this:</p> <ul> <li>The C equivalence of a java class should be in a pair of .c/.h files. Its data (be it private or public) is contained in a struct (preferably declared in the .c file only). Every function declared in the .h file has a pointer to its struct as a parameter. The .h file only needs to contain a declaration of the struct.</li> <li>The C equivalence of a java package is not possible to achieve by anything but locating the files in different directories. However, due to the single global namespace, it is still mandatory to prefix each non-static function and type with something unique, for examle XXXNAME_YYYNAME_ZZZNAME_FunctionName(), where XXXNAME is the name of the company, YYYNAME is the name of the product or library, and ZZZNAME is the name of the subpackage within the product/library. I have noticed that it is in real life not so common that the companyname is used at all, and if the product/library is "small", that is not used either.</li> <li>(Single) inheritance can easily be implemented by putting the "baseclass"'s struct as the first element of the struct of a "subclass". The inheritance structure is however not easily possible to expose to the client without exposing the entire struct.</li> </ul> <p>Example header file:</p> <pre><code>struct CARLIB_Car_s; void CARLIB_Car_Drive(struct CARLIB_Car_s *pCar, uint16_t KiloMeters); </code></pre> <p>Example source file:</p> <pre><code>struct CARLIB_Car_s { uint16_t FuelLeft; }; void CARLIB_Car_Drive(struct CARLIB_Car_s *pCar) { // ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload