【實驗】STL增加程式包大小

來源:互聯網
上載者:User
文章目錄
  • 實驗
  • 結論

stl確實經典~ STL會增大產生的程式包大小,程式包:exe,lib,dll。

實驗

1. main函數空時:

int main(){return 0;}

沒有引用任何檔案。exe大小為:

2. 加入c標準庫引用:

#include <stdio.h>#include <stdlib.h>int main(){printf("test");getchar();return 0;}

程式包並沒有明顯變化,大小仍然為28.5k

3. 加入STL的string:

#include <stdio.h>#include <stdlib.h>#include <string>int main(){std::string str = "test\n";printf(str.data());getchar();return 0;}

注意STL中都為模板類,如果沒有執行個體化對象,並不會連結。

加入string後exe大小為:

4.  加入vector

#include <stdio.h>#include <stdlib.h>#include <string>#include <vector>int main() {std::string str = "test\n";std::vector< int > vect;vect.push_back( 1 );printf(str.data());printf("%d\n", vect[0]);getchar();getchar();return 0;}

產生的exe包大小:

結論

加入vector後包大小已經翻倍了,好吧 常規的一些功能庫 最好DIY吧。。。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.