format not a string literal and no format arguments

最近在linux下編譯ORTP源碼過程當中,遇到以下問題,在網上也沒有找到很好的解決方案,不過在作了一些嘗試後,問題終於解決了,在此作個筆記~~~linux

編譯報錯:   error: format not a string literal and no format arguments微信

產生該錯誤的環境:學習

關鍵點:被編譯的文件中有以下形式的代碼:this

 
  1. char *pTestStr = " this is a test !";  
  2.  
  3. printf(pTestStr);  

而且每每在Ubuntu下編譯上述代碼時容易出現編譯報錯。.net

解決方法:orm

將printf(pTestStr)語句 改成:blog

printf("%s",pTestStr);get

個人系統爲Ubuntu 9.10,gcc版本爲4.4.1,多是該gcc版本對代碼檢查比較嚴格致使的問題。源碼

 

結束語博客

 

免費學習更多精品課程,登陸樂搏學院官網http://www.learnbo.c/

或關注咱們的官方微博微信,還有更多驚喜哦~

本文出自 「Jhuster的專欄」 博客,請務必保留此出處http://ticktick.blog.51cto.com/823160/311614

相關文章
相關標籤/搜索