No, it has nothing to do with RTEMS in particular. Any C program will do this.

> On 2019-June-27, at 21:17, Jython <googch...@gmail.com> wrote:
> 
> so it is rtems build requirement?
> 
> On Thu, Jun 27, 2019 at 2:53 AM Mr. Andrei Chichak <gro...@chichak.ca 
> <mailto:gro...@chichak.ca>> wrote:
> Assume that you are using C and C has a facility to bind together object 
> modules from different files.
> 
> You define a function in one file, it has a bunch of parameters and doesn’t 
> return anything.
> 
> In another file you use that function but don’t have a prototype that tells 
> the compiler anything about the function.
> 
> Now assume that the compiler was written in 1972, and doesn’t benefit from 
> things like mind reading.
> 
> C assumes, by default, that a function has one integer parameter and returns 
> an integer, unless otherwise told. What other choices has it got? Nothing 
> really. 
> 
> So in later versions of C, they introduced a thing called a prototype that 
> gives the compiler a hint about the parameters and return values of a 
> function.
> 
> All that you needed was to take your function header, put a semicolon on the 
> end and paste it before the call to the function and the compiler would have 
> done what you wanted instead of what you said.
> 
> Better yet, take that prototype and put it into a header file and whenever 
> you want to call the function, put in an include statement, the compiler 
> get’s the information about the parameters and return values, and overrides 
> the int func( int) default nature.
> 
> A
> 
>> On 2019-June-26, at 12:41 AM, Jython <googch...@gmail.com 
>> <mailto:googch...@gmail.com>> wrote:
>> 
>> I have a function named  oled_write_temp in a.c, if i dont declare it in a.h 
>> , then i will get the wrong supply value in the function within main call, 
>> why?
>> 
>> if i  declare it in a.h, then all is right
>> 
>> void oled_write_temp(float set_temp, const float supply, float return_temp)
>> {
>> 
>>     int base_x = 12, base_y = 60;
>> 
>>     char buffer[20] = {0};
>> 
>>     printf("supply_temp %f at %s\n", supply, __FUNCTION__);
>>     
>>     snprintf(buffer, 20, "SUPPLY:%.2f", supply);
>>     printf("supply_temp string %s\n", buffer);
>> 
>>     oled_clear_area(base_x, base_y + 16, 122, base_y + 32);
>>     OLED_ShowString(base_x, base_y + 16, buffer, 16, 1);
>> 
>>     memset(buffer, 0, sizeof(buffer));
>>     snprintf(buffer, 20, "RETURN:%.2f", return_temp);
>>     OLED_ShowString(base_x, base_y + 36, buffer, 16, 1);
>> 
>>     memset(buffer, 0, sizeof(buffer));
>>     snprintf(buffer, 20, "SET   :%.2f", set_temp);
>>     OLED_ShowString(base_x, base_y + 56, buffer, 16, 1);
>> 
>> }
>> 
>> ps: watch line  printf("supply_temp %f at %s\n", supply, __FUNCTION__);
>> _______________________________________________
>> users mailing list
>> users@rtems.org <mailto:users@rtems.org>
>> http://lists.rtems.org/mailman/listinfo/users 
>> <http://lists.rtems.org/mailman/listinfo/users>
> 

_______________________________________________
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Reply via email to