簡體   English   中英

在cpp中時,編譯器始終會編譯未使用的函數

[英]Compiler always compiles unused function when in cpp

即使我不使用此功能,如果該功能在cpp中實現(由於attachInterrupt()),它也總是使用4個字節的ram。 如果我在.h中內聯,它不會編譯任何內容

.h
// attach the interrupt function
void IRLbegin(const uint8_t interrupt);

.cpp
void IRLbegin(const uint8_t interrupt){
// attach the function that decodes the signals
attachInterrupt(interrupt, IRLinterrupt, CHANGE);
}

我該怎么辦? 我認為以.h編寫所有內容並不是很好的編碼風格。 由於Arduino環境,我無法更改優化設置。

在標題中可以很好地內聯簡單地調用另一個函數的函數。 嘗試使用IDE的1.5.8版本,因為它具有較新的編譯器,並且通常會在我發現的.CPP中內聯小型函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM