meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
programming:c:ceedling [2021/04/22 12:02] niziakprogramming:c:ceedling [2021/04/22 16:42] niziak
Line 1: Line 1:
 ====== Ceedling ====== ====== Ceedling ======
   * **support files ** - additional C files needed for tests but not for project (not added to project src).   * **support files ** - additional C files needed for tests but not for project (not added to project src).
-  + 
 +====== Hints ====== 
 +  Orgranize code into very small functional modules. 
 +  * Make separate ''.h'' for each ''.c'' module. 
 +  * Try to create separate ''.h'' for types and separate for function prototypes (it helps later with mocking) 
 +  * Always wrap HAL or other lower parts using some thin wrappers 
 ===== add .c file  ===== ===== add .c file  =====
  
Line 26: Line 32:
 </code> </code>
  
 +===== extern keyword =====
 +<code>
 +WARNING: No function prototypes found!
 +</code>
 +By default ''cmock'' will ignore ''extern'' function (is not mocking them). To enable mocking of ''extern'' functions:
 +<code yaml>
 +:cmock:
 +  :treat_externs: :include
 +</code>
  
  
 +===== volatile function parameters =====
 +<code c>
 +void myfn(custom_t *m, volatile uint32_t *var);
 +
 +error: conflicting types for ...
 +</code>
 +
 +[[https://github.com/ThrowTheSwitch/CMock/issues/135|CMock chokes on volatile function parameters #135]]
  
 +  The C99 standard recommends against using volatile as function call parameters and as return values, 
 +  stating that it is undefined behavior (because it is implementation-  specific) and therefore should 
 +  not be depended upon.
  
 +  * **Workaround1:** is to use macro for volatile and redefine it to nothing when ''TEST''.
 +  * **Workaround2:** is to use ''typedef volatile uint32_t my_volatile_type;''