This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 编译器/CCStudio-MSP:"检测到的连续位字段分配"和"UTC到TM转换问题"

Guru**** 2387060 points
Other Parts Discussed in Thread: MSP430FR5989
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/601766/compiler-ccstudio-msp-detected-consecutive-bitfield-assigns-and-utc-to-tm-conversion-problem

部件号:CCStudio-MSP
主题中讨论的其他部件:MSP430FR5989

工具/软件:TI C/C++编译器

IDE:CCS 6.1
编译器:TI v 4.4 .................3.
MCU:MSP430FR5989

-----------------------

unit_8 rtc_c_rtc2utc (时间t *UTC_time)

   unit_8 rtc_c_value[rtc_array_size];
   结构TM RTC_TM;

   rtc_c_read_cale (rtc_c_value);
   rtc_tm.tm_sec = rtc_c_value[6];
   rtc_tM.tm_min = rtc_c_value[5];
   rtc_tM.tm_hour = rtc_c_value[4];
   rtc_tm.tm_mdday = rtc_c_value[3]+ 1;
   rtc_tM.tm_mon = rtc_c_value[2]- 1;
   rtc_tM.tm_year = rtc_c_value[0]* 256 + rtc_c_value[1]- 1970;
   rtc_tm_isdst =-1;

   *UTC_TIME = mktime(&RTC_TM)- local_timezone;

   返回0;
}

-----------------------

1.在符合上述计划后,建议"(ULP 15.1)检测到连续的位字段分配。 建议改用位掩码”在“rtc_tM.tm_min = rtc_c_value[5];”和“rtc_tm_tm_isdst =-1;”行中出现6次,但我不能理解我使用位字段分配的位置?

2.在Time.h中,显示如下:

--------

结构TM

.....
   int tm_mdday;    /*每月的某一天          -[1,31]*/  
...
   int tm_year;    /* 1900年以来的年份                    */
.....
};

--------

但实际上,我必须将当月的当前日期与1970相加,减去当前年份,以获得正确的UTC时间。 我已阅读链接

但我找不到添加或删除__TI_Time_Uses_64的位置。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    如果要使用64位POSIX兼容时间,则需要将预处理程序宏__TI_TIME_USS_64定义为命令行选项,例如:-D__TI_TIME_USS_64=1
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    我在TI维客上找到了此文章:
    processors.wiki.ti.com/.../Time_and_clock_RTS_Functions
    根据上述文章,默认Time_t为32位,时间从1900 CST-0600年1月1日开始,如果我定义__TI_Time_Uses_64,则Time_t为64位,从1970年1月1日开始。
    但我的mktime()函数总是输出一个从1970年1月1日开始的时间,在32位的time_t中,它不适合上面的任何定义。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    编译函数时,是否将__TI_Time_Uses_64定义为值1?