Bromania Wiki

Scribblings of a Brit in Romania

User Tools

Site Tools


tech:unix:freebsd:uint

Differences

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

Link to this comparison view

tech:unix:freebsd:uint [2024/05/21 15:33] – created puisortech:unix:freebsd:uint [2024/05/22 08:07] (current) puisor
Line 10: Line 10:
 ===== Symptom ===== ===== Symptom =====
  
-When attempting to compile a C program (probably one you downloaded from the internet), in either ''clang'' or ''gcc'', you encounter an error similar to this one:+When attempting to compile a C program, in either ''clang'' or ''gcc'', you encounter an error similar to this one:
  
   myprogram.c:600:2: error: use of undeclared identifier 'uint'; did you mean 'int'?   myprogram.c:600:2: error: use of undeclared identifier 'uint'; did you mean 'int'?
Line 20: Line 20:
 ===== Root Cause ===== ===== Root Cause =====
  
-''uint'' is not a [[https://en.wikipedia.org/wiki/C_data_types|standard C data type]], however it is used by other platforms, such as Linux.+''uint'' is not a [[https://en.wikipedia.org/wiki/C_data_types|standard C data type]], so it must be declared.
  
  
 ===== Solution ===== ===== Solution =====
  
-To resolve this issue, declare the ''uint'' type before ''main'' in the C source file, for example:+Include the ''sys/types.h'' header file before ''main'' in the C source file:
  
-  typedef __uint32_t uint;  +  #include <sys/types.h> 
  
 The program should then compile. The program should then compile.
tech/unix/freebsd/uint.txt · Last modified: 2024/05/22 08:07 by puisor