[問題] sturct/union extern後又定義 沒有問題?
win10
compiler: Microchip xc8
In the header File:
typedef union
{
uint8_t Bytes[4];
uint32_t Word;
}BYTES_TO_WORD;
extern BYTES_TO_WORD MyBytes;
In the 'C' File with the declairation in it
#include "commonheaderfile.h"
BYTES_TO_WORD MyBytes;
in other 'C' files
#include "commonheaderfile.h"
MyBytes.Word=123445677;
上述這樣是正常運作,結果我不小心在other 'C' file也下了BYTES_TO_WORD MyBytes;
編譯還是過,運作也沒問題,奇怪這樣不是重複定義?
BYTES_TO_WORD MyBytes; 不就會給記憶體區塊了嗎?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.216.7.85 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1564458186.A.ADE.html
推
07/30 11:46,
6年前
, 1F
07/30 11:46, 1F
→
07/30 11:52,
6年前
, 2F
07/30 11:52, 2F
→
07/30 11:54,
6年前
, 3F
07/30 11:54, 3F
→
07/30 11:54,
6年前
, 4F
07/30 11:54, 4F
→
07/30 12:04,
6年前
, 5F
07/30 12:04, 5F
推
07/30 14:55,
6年前
, 6F
07/30 14:55, 6F
→
07/30 15:27,
6年前
, 7F
07/30 15:27, 7F
推
07/30 16:34,
6年前
, 8F
07/30 16:34, 8F
→
07/30 17:50,
6年前
, 9F
07/30 17:50, 9F
→
07/30 17:50,
6年前
, 10F
07/30 17:50, 10F
→
07/30 17:57,
6年前
, 11F
07/30 17:57, 11F
推
07/30 23:18,
6年前
, 12F
07/30 23:18, 12F
→
07/30 23:49,
6年前
, 13F
07/30 23:49, 13F
※ 編輯: anoymouse (59.115.118.133 臺灣), 07/30/2019 23:50:32
→
07/31 09:26,
6年前
, 14F
07/31 09:26, 14F
→
07/31 09:27,
6年前
, 15F
07/31 09:27, 15F
→
07/31 09:27,
6年前
, 16F
07/31 09:27, 16F
→
07/31 10:02,
6年前
, 17F
07/31 10:02, 17F
→
07/31 10:02,
6年前
, 18F
07/31 10:02, 18F
→
07/31 10:03,
6年前
, 19F
07/31 10:03, 19F
→
07/31 10:04,
6年前
, 20F
07/31 10:04, 20F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章