1. 程式人生 > >使用memset、memcpy等函式需要包含string.h而不是strings.h

使用memset、memcpy等函式需要包含string.h而不是strings.h

問題:

frm_package.c中呼叫了memset()和memcpy()函式,但是沒有包含相應的標頭檔案,編譯時出現錯誤:

[email protected]:~/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocket/isocket$ make
gcc -g3 -Wall -o0 -c nettrans.c -o nettrans.o
gcc -g3 -Wall -o0 -c tcpclient.c -o tcpclient.o
gcc -g3 -Wall -o0 -c frm_package.c -o frm_package.o
frm_package.c: In function ‘package_frm’:
frm_package.c:96:2: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]
frm_package.c:96:2: warning: incompatible implicit declaration of built-in function ‘memcpy’ [enabled by default]
frm_package.c:97:2: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration]
frm_package.c:97:2: warning: incompatible implicit declaration of built-in function ‘memset’ [enabled by default]
frm_package.c: In function ‘ack_ctrl’:
frm_package.c:231:2: warning: incompatible implicit declaration of built-in function ‘memcpy’ [enabled by default]
frm_package.c:232:2: warning: incompatible implicit declaration of built-in function ‘memset’ [enabled by default]
frm_package.c:246:7: error: ‘ctrls’ undeclared (first use in this function)
frm_package.c:246:7: note: each undeclared identifier is reported only once for each function it appears in
frm_package.c:224:9: warning: variable ‘id’ set but not used [-Wunused-but-set-variable]
frm_package.c: In function ‘parse_ctrl’:
frm_package.c:328:2: warning: implicit declaration of function ‘ctrl_init’ [-Wimplicit-function-declaration]
frm_package.c:348:7: warning: implicit declaration of function ‘ctrl_add’ [-Wimplicit-function-declaration]
frm_package.c:366:5: warning: incompatible implicit declaration of built-in function ‘memcpy’ [enabled by default]
frm_package.c:366:12: error: ‘date_time’ undeclared (first use in this function)
frm_package.c:368:5: warning: implicit declaration of function ‘rtc_write’ [-Wimplicit-function-declaration]
frm_package.c:323:5: warning: unused variable ‘k’ [-Wunused-variable]
make: *** [frm_package.o] Error 1

於是,在frm_package.c中包含了標頭檔案<strings.h>,再次使用make clean;make編譯,出現的編譯錯誤還是一模一樣。

解決辦法:

1. 經查詢交叉編譯工具鏈ELDK42下的./arm/usr/include/strings.h檔案,確實沒有memcpy()和memset();

這是怎麼回事呢?

難道是包含的標頭檔案出錯了?

到原來使用memset()函式的原始檔中去看了下,果然是包含錯了,應該包含的是標頭檔案<string.h>,而不是<strings.h>;

改為包含<string.h>,再次編譯,錯誤消失。

問題解決。

相關推薦

使用memsetmemcpy函式需要包含string.hstrings.h

問題: frm_package.c中呼叫了memset()和memcpy()函式,但是沒有包含相應的標頭檔案,編譯時出現錯誤: [email protected]:~/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocke

CString/string /Char轉化Vector分割NewMallocMemsetMemcpyStrcpystatic

#include "stdafx.h" #include <string> // #include <stdlib.h> #include <stdio.h> #include <iostream> using namespa

python裡面的xlrd模組詳解 ♦ python解決open()函式xlrd.open_workbook()函式檔名包含中文,sheet名包含中文報錯的問題

那我就一下面積個問題對xlrd模組進行學習一下: 1.什麼是xlrd模組? 2.為什麼使用xlrd模組? 3.怎樣使用xlrd模組? 1.什麼是xlrd模組?   ♦python操作excel主要用到xlrd和xlwt這兩個庫,即xlrd是讀excel,xlwt是寫ex

本週學習總結 第十週 C++中cincin.get()cin.getline()getline()gets()函式的用法

   先總結幾個string字元陣列常用函式把 需要<string.h>標頭檔案才可以使用:  strlen(字元陣列) 、 strcpy(陣列1,陣列2)把2內容複製到1中去 、 strcat(陣列1,陣列2) 將2中內容連到1中去 、 strcmp(陣

IOS中正弦sincos函式運算的坑

在ios中可以完全相容c的函式,所以第一步要匯入 #include <math.h> 這樣就可以使用c的一系列函數了 c中有cos,sin,tan但是我們傳入度數後都得不到想到的結果,問題是: 我們傳入的是度數,而函式所需的引數是弧度,這裡就要我們做一個度--弧度的轉換

【python】詳解time模組功能asctimelocaltimemktimesleepstrptimestrftimetime函式以及時間的加減運算

在Python中,與時間處理相關的模組有:time、datetime以及calendar。學會計算時間,對程式的調優非常重要,可以在程式中狂打時間戳,來具體判斷程式中哪一塊耗時最多,從而找到程式調優的重心處。這裡先來講一個time模組。 time模組所包含的函式能夠實現以下功能:獲取當前的時間、操作時間和日

SQL中AVG()COUNT()SUM()函式對NULL值處理

原文連結:https://blog.csdn.net/whaxrl/article/details/51195241 一、AVG() 求平均值 注意AVE()忽略NULL值,而不是將其作為“0”參與計算 二、COUNT() 兩種用法 1、COUNT

C#實現計算給定報文的HASH值,其中包括SHA1SHA256MD5函式的使用

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO

C++中cincin.get()cin.getline()getline()gets()函式的用法

學C++的時候,這幾個輸入函式弄的有點迷糊;這裡做個小結,為了自己複習,也希望對後來者能有所幫助,如果有差錯的地方還請各位多多指教(本文所有程式均通過VC 6.0執行) 1、cin 2、cin.get() 3、cin.getline() 4、getline() 5、gets() 6、getchar() 附

【不斷更新貼】總結程式設計的技巧語法需要多敲程式碼記憶掌握

1. void DrawRectangle( cv::Mat& img, cv::Rect  box ) { cv::rectangle(img,box.tl(),box.br(),cv::Scalar(g_rng.uniform(0, 255), g_rng.uni

kotlin之pluscopyOfreverseforEachfiltermapreducefold函式解釋和使用

kotlin之::函式呼叫、plus(增加元素)、copyOf(複製陣列)、reverse(翻轉陣列)、forEach(遍歷陣列)、filter(過濾陣列)、map函式操作及擴充套件、reduce函式、fold函式、filter、filterIndexed、takeWhile、infix關鍵字等的解釋和使用示

python裡面的xlrd模組 ♦ python解決open()函式xlrd.open_workbook()函式檔名包含中文,sheet名包含中文報錯的問題

 ♦python操作excel主要用到xlrd和xlwt這兩個庫,即xlrd是讀excel,xlwt是寫excel的庫。 今天就先來說一下xlrd模組: 一、安裝xlrd模組   ♦ 到python官網下載http://pypi.python.org/pypi/xlrd模組安裝,前提是已經安裝了pyth

table()tapply()函式輸出的結果取值和應用辦法

參考:https://www.zhihu.com/question/46661384 table()的輸出可以看成是一個帶名字的數字向量。可以用names()和as.numeric()分別得到名稱和頻數: > x <- sample(c("a", "b"

解決VS2017報錯fopensprintf函式安全的問題

VS2017中使用fopen、sprintf等函式會出現安全問題,如下: error C4996: ‘fopen’: This function or variable may be unsafe.

cincin.get()cin.getline()getline()gets()函式的用法

學C++的時候,這幾個輸入函式弄的有點迷糊;這裡做個小結,為了自己複習,也希望對後來者能有所幫助,如果有差錯的地方還請各位多多指教(本文所有程式均通過VC 6.0執行)轉載請保留作者資訊; 1、cin 1、cin.get() 2、cin.getline() 3、getli

解決vs2015使用fopenfprintf函式報錯的問題

出現錯誤提示: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online

C++學習筆記26 size()length()函式的返回值的問題

c++ string類length()、size()等函式返回值屬於無符號數 首先看一個例子 string s = ""; for(int i = 0; i < s.length() - 1; ++i) { cout << "s.

C++中的cincin.get()cin.getline()getline()gets()函式的用法

1、cin 2、cin.get() 3、cin.getline() 4、getline() 5、gets() 6、getchar() 1.cin>> 用法1:最基本,也是最常用的用法,輸入一個數字: #include <iostream>

C++容器中勿使用memsetmemcpy

當一個數據結構中,包含map表,list表,vactor等容器時,勿使用memset初始化該結構。 否則,會導致該結構資訊不可用。 map表在初始化時,會自動呼叫建構函式,若memset後,那麼建構函式就會被破壞,導致構造失敗,進而導致map表不可用。 切記!切記!

解決Windows下PHP的execshell_exec函式能正常執行的方法

  在Windows平臺下安裝PHP後,在使用PHP的exec、shell_exec等函式時,經常會遇到報錯:unable to fork...,這實際上是因為PHP對cmd.exe沒有足夠的許可權引起的。 解決方法:為C:\Windows\System32\cmd.exe