作者peng0116 ()
看板C_and_CPP
標題[問題] struct如何使用extern
時間Mon Aug 24 17:34:51 2015
問題(Question):
我的平台有coreA和coreB,各有main(),在main()內宣告的變數皆使用 L1 記憶體,
(平台記憶體有L1、L2_SRAM、L3_SDRAM)
想在L2_SRAM.h下宣告struct
而在system.h下extern struct,讓在其他.c檔只要#include system.h
就可以使用此struct...但出現錯誤如下,
請問有人知道我的問題出在哪裡嗎...?懇請告知謝謝
<L2_SRAM.h>
struct my_struct
{
int x;
int y;
};
<system.h>
extern struct my_struct MYSTRUCT;
<main.c>
MYSTRUCT.x = 10; //編譯出現錯誤
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.251.198.39
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1440408894.A.D68.html
推 stupid0319: 你要不要在L2_SRAM.h加一行 my_struct MYSTRUCT; 08/24 17:59
推 kwpn: 要了解什麼是變數的宣告式、什麼是變數的定義式 08/24 18:09
→ bdvstg: ADI blackfin? 08/24 19:20
→ EdisonX: system.h 有 include "L2_SRAM.h" 嗎? 08/24 22:13
推 chuegou: 1.2F意見+1 08/24 22:55
→ bibo9901: extern的意思跟你想的正好相反 08/25 12:44