C語言結構體賦值問題

【問題描述】數組

       以前的系統參數用一個結構體變量tempBasicInfo來保存,成員類型有:uint8_t、uint16_t、結構體,結構體成員爲uint8_t、uint16_t;今天須要添加一系列參數,用了一個uint8_t和三個uint8_t數組;之前配置完tempBasicInfo後會將其賦給常駐的stBasicInfo: ui

    stBasicInfo = tempBasicInfo;spa

    增長數組成員後,編譯無錯,可是調試時出現異常,如:斷點不停,或是有時單步能夠,忽然某一步直接run了;調試

【問題處理】code

     查了半天,才定位到這裏,用memcpy替代後,正常。謹記之~!!!編譯

typedef struct	                              // 基本系統參數
	{
		uint8_t         CfgFlag;			  
		uint8_t	        ProtocolType;		  
		uint8_t         Operator;			  
		uint16_t        CollectInterval;	  
		uint16_t        UploadInterval;     
		uint8_t         TotalNum;			  
		structIPAddress IPAddress;	          // IP address & port NO.

#if defined(xxx)
		uint16_t        dtuTempUploadInt;
		uint16_t        statUploadInt;
		uint16_t        tempUploadInt;
            
		uint8_t         para_f4;                        // dtu uplink parameters
		uint8_t         para_f10[PARA_LEN_DOWN_LINK];   // dtu down-link parameters
		uint8_t         para_f29[PARA_LEN_UPLOAD_DATA]; // control parameters of upload data
		uint8_t         para_f31[PARA_LEN_TIME];        // time parameters of dtu
#endif
	}strcBasicInfo;
相關文章
相關標籤/搜索