vs2010創建和使用動態鏈接庫(dll)

***************************************************

更多精彩,歡迎進入:http://shop115376623.taobao.com

***************************************************


本文將創建一個簡單的動態鏈接庫,并編寫一個應用臺控制程序使用該動態鏈接庫,并提出了與實現相關的幾個問題,供初學者交流。

本文包含以下內容:

1、創建動態鏈接庫項目

2、向動態鏈接庫添加類

3、創建引用動態鏈接庫的應用程序

4、在控制臺應用程序中使用類庫的功能

5、更豐富的simpledll類和相關問題

參考資料

一、創建動態鏈接庫項目:

1、打開Microsoft?Visual?Studio?2010,選擇File->New->Project

2、在New?Project中選擇Installed?Templates->Visual?C++->Win32

3、選擇Win32?Console?Application,設置名稱:simpledll,設置解決方案名:zdddll

4、單擊OK,在出現的Win32?Application?WizardOverview對話框中點擊Next

5、在Application?Settings中,選擇Application?type下的DLL

6、勾選Additional?options下的Empty?project

7、單擊Finish創建項目。

二、向動態鏈接庫添加類:

1、添加新類頭文件。右鍵單擊simpledll項目,Add->New?Item,選擇Header?File(.h),設置名稱為simpledll,單擊Add

2、添加新類源文件。右鍵單擊simpledll項目,Add->New?Item,選擇C++?File(.cpp),設置名稱為simpledll,單擊Add

3、為新類添加內容。內容如下:

頭文件simpledll.h:

[html]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. //------------------?simpledll.h?----------------??
  2. ??
  3. #pragma?once;??
  4. ??
  5. //該宏完成在dll項目內部使用__declspec(dllexport)導出??
  6. //在dll項目外部使用時,用__declspec(dllimport)導入??
  7. //宏DLL_IMPLEMENT在simpledll.cpp中定義??
  8. #ifdef?DLL_IMPLEMENT??
  9. #define?DLL_API?__declspec(dllexport)??
  10. #else??
  11. #define?DLL_API?__declspec(dllimport)??
  12. #endif??
  13. ??
  14. namespace?zdd??
  15. {??
  16. ????//導出類??
  17. ????class?DLL_API?SimpleDll??
  18. ????{??
  19. ????public:??
  20. ????????SimpleDll();??
  21. ????????~SimpleDll();??
  22. ??
  23. ????????int?add(int?x,?int?y);?//簡單方法??
  24. ????};??
  25. }??

源文件simpledll.cpp:

[cpp]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. //------------------?simpledll.cpp?----------------??
  2. ??
  3. //注意此處的宏定義需要寫在#include?"simpledll.h"之前??
  4. //以完成在dll項目內部使用__declspec(dllexport)導出??
  5. //在dll項目外部使用時,用__declspec(dllimport)導入??
  6. #define?DLL_IMPLEMENT???
  7. ??
  8. #include?"simpledll.h"??
  9. ??
  10. namespace?zdd??
  11. {??
  12. ????SimpleDll::SimpleDll()??
  13. ????{??
  14. ??
  15. ????}??
  16. ??
  17. ????SimpleDll::~SimpleDll()??
  18. ????{??
  19. ??
  20. ????}??
  21. ??
  22. ????int?SimpleDll::add(int?x,?int?y)??
  23. ????{??
  24. ????????return?x+y;??
  25. ????}??
  26. }??

4、完成后點擊Build->Build?Solution,生成解決方案。可在~zdddll\Debug下查看生成的simpledll.libsimpledll.dll.文件。

三、創建引用動態鏈接庫的應用程序:

1、選擇File->New->Project

2、在New?Project中選擇Installed?Templates->Visual?C++->Win32

3、選擇Win32?Console?Application,設置名稱:usesimpledll。選擇Add?to?solution

4、單擊OK,在出現的Win32?Application?WizardOverview對話框中點擊Next

5、在Application?Settings中,選擇Application?type下的Console?application

6、取消Additional?options下的Precompiled?header,勾選Empty?project

7、單擊Finish創建項目。

四、在控制臺應用程序中使用類庫的功能:

1、為控制臺應用程序添加main.cpp。右鍵單擊usesimpledll項目,Add->New?Item,選擇C++?File(.cpp),設置名稱為main,單擊Add

2、為main.cpp添加內容。如下所示:

[cpp]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. //------------------?main.cpp?-------------------??
  2. #include?"simpledll.h"??
  3. using?namespace?zdd;??
  4. ??
  5. #include?<iostream>??
  6. using?namespace?std;??
  7. ??
  8. int?main(char?argc,?char**argv)??
  9. {??
  10. ????//??
  11. ????cout?<<?"----------------------"?<<endl;??
  12. ????SimpleDll?sd;??
  13. ????cout?<<?"sd.add:?3+5="?<<?sd.add(3,?5)<<endl;??
  14. ????cout?<<?"sd.getConst():?"<<sd.getConst()<<endl;??
  15. ??
  16. ????SimpleDll?*psd?=?new?SimpleDll;??
  17. ????cout?<<?"psd->add:?5+5="?<<?psd->add(5,?5)<<endl;??
  18. ????cout?<<?"psd->getConst():?"<<endl;??
  19. ??
  20. ????cout?<<?"----------------------"?<<endl;??
  21. ????cout?<<?"please?press?Enter?exit."<<endl;??
  22. ????getchar();??
  23. ????return?0;??
  24. }??

3、引用simpledll項目。右鍵單擊usesimpledll項目,選擇Properties->Common?Properties->Framework?and?References。點擊Add?New?Reference,選擇simpledll項目,單擊OK

4、設置頭文件路徑。選擇Properties->Configuration?Properties->VC++?Directories。在Include?Directories項添加$(SolutionDir)\simpledll\,選擇應用,確定。

5、設置usesimpledll項目為活動項目。右鍵單擊usesimpledll項目,選擇Set?up?StartUp?Project

6、生成解決方案。Debug運行結果如下:

[cpp]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. 3+5=8??
  2. 5+5=10??

五、更豐富的simpledll類和相關問題:

simpledll.h文件:

[cpp]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. //------------------?simpledll.h?----------------??
  2. ??
  3. #pragma?once;??
  4. ??
  5. //該宏完成在dll項目內部使用__declspec(dllexport)導出??
  6. //在dll項目外部使用時,用__declspec(dllimport)導入??
  7. //宏DLL_IMPLEMENT在simpledll.cpp中定義??
  8. #ifdef?DLL_IMPLEMENT??
  9. #define?DLL_API?__declspec(dllexport)??
  10. #else??
  11. #define?DLL_API?__declspec(dllimport)??
  12. #endif??
  13. ??
  14. namespace?zdd??
  15. {??
  16. ????//導出類??
  17. ????class?DLL_API?SimpleDll??
  18. ????{??
  19. ????public:??
  20. ????????SimpleDll();??
  21. ????????~SimpleDll();??
  22. ??
  23. ????????int?add(int?x,?int?y);?//簡單方法??
  24. ??
  25. ????????static?int?sub(int?x,?int?y);//靜態方法??
  26. ??
  27. ????????int?getConst();?//??
  28. ??
  29. ????????int?getNum();??
  30. ??
  31. ????private:??
  32. ????????void?setNum(int?n);??
  33. ????????int?num;??
  34. ????};??
  35. ??
  36. ????//全局變量??
  37. ????int?DLL_API?number;???
  38. ????SimpleDll?DLL_API?sdd;??
  39. ??
  40. ????//對于指針,下面兩種用法沒區別???
  41. ????SimpleDll?DLL_API?*psdd;??
  42. ????SimpleDll?*psdd1;??
  43. ??
  44. ????//方法??
  45. ????int?DLL_API?Add(int?a,?int?b);??
  46. ??
  47. ????SimpleDll?*createClass()??
  48. ????{??
  49. ????????return?new?SimpleDll;??
  50. ????}??
  51. ??
  52. /*?
  53. ????//問題1:若這樣使用,則出現如下錯誤:?
  54. ????//?error?C2059:?syntax?error?:?'__declspec(dllexport)'?
  55. ????//?error?C2143:?syntax?error?:?missing?';'?before?'{'?
  56. ????//?error?:?'__declspec(dllimport)'?
  57. ????//?error?C2143:?syntax?error?:?missing?';'?before?'{'?
  58. ????//?error?C2447:?'{'?:?missing?function?header?(old-style?formal?list?)?
  59. ????//為什么??
  60. ????SimpleDll*?DLL_API?createClass1()?
  61. ????{?
  62. ????????return?new?SimpleDll;?
  63. ????}?
  64. */??
  65. ??
  66. /*?
  67. ????//問題2:若這樣使用,則出現如下錯誤:?
  68. ????//Error?1???error?C2491:?'zdd::createClass1'?:?definition?of?dllimport?function?not?allowed?usesimpledll?
  69. ????//為什么??
  70. ????SimpleDll?DLL_API?*?createClass2()?
  71. ????{?
  72. ????????return?new?SimpleDll;?
  73. ????}?
  74. */??
  75. ????//問題3:這樣使用(實現在.cpp中),編譯沒有問題。??
  76. ????//但在main中應用時回出現以下錯誤:??
  77. ????//?error?LNK2019:?unresolved?external?symbol?"class?zdd::SimpleDll?*?__cdecl?zdd::createClass3(void)"?(?createClass3@zdd@@YAPAVSimpleDll@1@XZ)?referenced?in?function?_main??
  78. ????//該如何解決???
  79. ????SimpleDll?*createClass3();?//先別這樣用??
  80. ??
  81. ????//全局方法加DLL_API和不加DLL_API時的區別??
  82. ????int?DLL_API?getConst1();??
  83. ????//int?getConst2();?//不要這樣使用??
  84. ??
  85. ????//也不要這樣用??
  86. ????//否則當程序發布之后,如果只想通過更新.dll??
  87. ????//來達到更新程序數據的目的,比如將此處的100更新成10.??
  88. ????//通過下面的方法你是做不到的??
  89. ????int?getConst2()??
  90. ????{??
  91. ????????return?100;??
  92. //??????return?10;??
  93. ????}??
  94. ??
  95. ????//也不要這樣用,否則將出現如下錯誤??
  96. ????//error?C2491:?'zdd::getConst3'?:?definition?of?dllimport?function?not?allowed??
  97. /*?
  98. ????int?DLL_API?getConst3()?
  99. ????{?
  100. ????????return?100;?
  101. ????}?
  102. */??
  103. ????//不要這樣用,同理??
  104. ????int?others(int?a)??
  105. ????{??
  106. ????????return?a+10;??
  107. ????}??
  108. }??

simpledll.cpp文件:

[cpp]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. //------------------?simpledll.cpp?----------------??
  2. ??
  3. //注意此處的宏定義需要寫在#include?"simpledll.h"之前??
  4. //以完成在dll項目內部使用__declspec(dllexport)導出??
  5. //在dll項目外部使用時,用__declspec(dllimport)導入??
  6. #define?DLL_IMPLEMENT???
  7. ??
  8. #include?"simpledll.h"??
  9. ??
  10. namespace?zdd??
  11. {??
  12. ????SimpleDll::SimpleDll()??
  13. ????{??
  14. ??
  15. ????}??
  16. ??
  17. ????SimpleDll::~SimpleDll()??
  18. ????{??
  19. ??
  20. ????}??
  21. ??
  22. ????int?SimpleDll::add(int?x,?int?y)??
  23. ????{??
  24. ????????return?x+y;??
  25. ????}??
  26. ??
  27. ????int?SimpleDll::sub(int?x,?int?y)??
  28. ????{??
  29. ????????return?x-y;??
  30. ????}??
  31. ??
  32. ????int?SimpleDll::getConst()??
  33. ????{??
  34. ????????return?10;?//??
  35. ????}??
  36. ??
  37. ????void?SimpleDll::setNum(int?n)??
  38. ????{??
  39. ????????num?=?n;??
  40. ????}??
  41. ??
  42. ????int?SimpleDll::getNum()??
  43. ????{??
  44. ????????return?num;??
  45. ????}??
  46. ??
  47. ????extern?int?number?=?5;??
  48. ??
  49. ????int?Add(int?a,?int?b)??
  50. ????{??
  51. ????????return?a+b;??
  52. ????}??
  53. ??
  54. ????SimpleDll?*createClass3()??
  55. ????{??
  56. ????????return?new?SimpleDll;??
  57. ????}??
  58. ??
  59. ????int?getConst1()??
  60. ????{??
  61. ????????return?100;??
  62. ????????//return?10;??
  63. ????}??
  64. /*?
  65. ????//error?
  66. ????extern?int?getConst2()?
  67. ????{?
  68. ????????return?100;?
  69. ????}?
  70. */??
  71. }??

main.cpp文件:

[cpp]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. //------------------?main.cpp?-------------------??
  2. #include?"simpledll.h"??
  3. using?namespace?zdd;??
  4. ??
  5. #include?<iostream>??
  6. using?namespace?std;??
  7. ??
  8. int?main(char?argc,?char**argv)??
  9. {??
  10. ????//??
  11. ????cout?<<?"----------------------"?<<endl;??
  12. ????SimpleDll?sd;??
  13. ????cout?<<?"sd.add:?3+5="?<<?sd.add(3,?5)<<endl;??
  14. ????cout?<<?"sd.getConst():?"<<sd.getConst()<<endl;??
  15. ??
  16. ????SimpleDll?*psd?=?new?SimpleDll;??
  17. ????cout?<<?"psd->add:?5+5="?<<?psd->add(5,?5)<<endl;??
  18. ????cout?<<?"psd->getConst():?"<<endl;??
  19. ??
  20. ????cout?<<?"----------------------"?<<endl;??
  21. ????cout?<<?"SimpleDll::sub:?2-1="?<<?SimpleDll::sub(2,1)<<endl;??
  22. ??
  23. ????cout?<<?"----------------------"?<<endl;??
  24. ????cout?<<?"zdd::number:?"<<number<<endl;??
  25. ????number?=?10;??
  26. ????cout?<<?"changed?zdd::number:?"<<number<<endl;??
  27. ??????
  28. ????cout?<<?"----------------------"?<<endl;??
  29. ????cout?<<?"sdd.add:?6+8="?<<?sdd.add(6,8)<<endl;??
  30. ????cout?<<?"psdd->add:?6+8="?<<psdd->add(6,8)<<endl;??
  31. ????cout?<<?"psdd1->add:?6+8="?<<psdd1->add(6,8)<<endl;??
  32. ??
  33. ????cout?<<endl;??
  34. ????cout?<<?"sdd.getConst():?"<<sd.getConst()<<endl;??
  35. ????cout?<<?"psdd.getConst():?"<<psdd->getConst()<<endl;??
  36. ????cout?<<?"psdd1.getConst():?"<<psdd1->getConst()<<endl;??
  37. ??
  38. ????cout?<<?"----------------------"?<<endl;??
  39. ????cout?<<?"zdd::Add:?7+8="<<Add(7,8)<<endl;??
  40. ??
  41. ????cout?<<?"----------------------"?<<endl;??
  42. ????SimpleDll?*p?=?createClass();??
  43. ????cout?<<?"create->add:?2+3="?<<p->add(3,2)<<endl;??
  44. ????cout?<<?"create->getConst():?"<<p->getConst()<<endl;??
  45. ????cout?<<?"----------------------"?<<endl;??
  46. ??
  47. //??SimpleDll?*p3?=?createClass3();??
  48. //??cout?<<?"create3->add:?2+3="?<<p3->add(3,2)<<endl;??
  49. //??cout?<<?"create3->getConst():?"<<p3->getConst()<<endl;??
  50. //??cout?<<?"----------------------"?<<endl;??
  51. ??
  52. ????cout?<<?"----------------------"?<<endl;??
  53. ????//請別在你的應用程序中使用getConst2??
  54. ????cout?<<?"DLL_API?getConst1:?"<<getConst1()<<endl;??
  55. ????cout?<<?"????????getConst2:?"<<getConst2()<<endl;??
  56. //??cout?<<?"DLL_API?getConst3:?"<<getConst3()<<endl;??
  57. ????cout?<<?"----------------------"?<<endl;??
  58. ??
  59. //??cout?<<?"others:?"?<<?others(6)<<endl;??
  60. //??cout?<<?"others:?"?<<?others(16)<<endl;??
  61. //??cout?<<?"----------------------"?<<endl;??
  62. ??
  63. ????cout?<<?"please?press?Enter?exit."<<endl;??
  64. ????getchar();??
  65. ????return?0;??
  66. }??

運行結果為:

[html]?view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. ----------------------??
  2. sd.add:?3+5=8??
  3. sd.getConst():?10??
  4. psd->add:?5+5=10??
  5. psd->getConst():???
  6. ----------------------??
  7. SimpleDll::sub:?2-1=1??
  8. ----------------------??
  9. zdd::number:?5??
  10. changed?zdd::number:?10??
  11. ----------------------??
  12. sdd.add:?6+8=14??
  13. psdd->add:?6+8=14??
  14. psdd1->add:?6+8=14??
  15. ??
  16. sdd.getConst():?10??
  17. psdd.getConst():?10??
  18. psdd1.getConst():?10??
  19. ----------------------??
  20. zdd::Add:?7+8=15??
  21. ----------------------??
  22. create->add:?2+3=5??
  23. create->getConst():?10??
  24. ----------------------??
  25. ----------------------??
  26. DLL_API?getConst1:?100??
  27. ????????getConst2:?100??
  28. ----------------------??
  29. please?press?Enter?exit.??

可將生成的可執行文件和應用程序拷出到同一目錄下,通過更改方法getConst1,getConst2,體會dllexport和dllimport的作用。
代碼中提出的幾個問題方法,暫時無解,暫不使用。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/458967.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/458967.shtml
英文地址,請注明出處:http://en.pswp.cn/news/458967.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

通用二進制

通用二進制 通用二進制&#xff08;Universal binary&#xff09;是蘋果電腦公司提出的一種程序代碼&#xff0c;使程序能以本地程序的形式運行在使用PowerPC或者英特爾微處理器&#xff08;x86&#xff09;的麥金塔電腦上&#xff0c;在同一個程序包中同時為兩種架構提供最理想…

Python~win32com~Excel

import win32com.client#wwin32com.client.Dispatch("Word.Application") #w.Visible1owin32com.client.Dispatch("Excel.Application") o.Visible1 o.Workbooks.Add() o.Cells(1,1).Value"Hello"轉載于:https://www.cnblogs.com/lynclynn/p/530…

linux顯示光盤命令行,使用wodim在命令行下燒錄光盤

使用wodim在命令行下燒錄光盤發布時間:2009-02-27 16:23:11來源:紅聯作者:zhania作者&#xff1a;linuxtoy出自http://linuxtoy.org/archives/burning-cd-with-wodim.html我們以前介紹的 Linux 光盤燒錄工具多為圖形化的程序&#xff0c;今天來看看如何使用 wodim 在命令行下燒…

Android(java)學習筆記144:網絡圖片瀏覽器的實現(ANR)

1.我們在Android下&#xff0c;實現使用http協議進行網絡通信&#xff0c;請求網絡數據。這里是獲取網絡上的圖片信息&#xff0c;讓它可以顯示在手機上&#xff1b; 但是我們這個手機連接網絡是很費時間&#xff0c;如果我們在主線程&#xff08;UI線程&#xff09;中寫這個網…

DLL導出函數名稱改編的解決方法

*************************************************** 更多精彩&#xff0c;歡迎進入&#xff1a;http://shop115376623.taobao.com *************************************************** 1.DLL編譯后導出函數名稱改變 在編寫一個DLL后&#xff0c;為了能被別的程序調用&…

組合自定義控件的步驟詳解

Android 步驟&#xff1a; 1 自定義組合控件的布局settint_view.xml<?xml version"1.0" encoding"utf-8"?> <RelativeLayout xmlns:android"http://schemas.android.com/apk/res/android"android:orientation"vertical"and…

linux如何建立隱藏目錄,【Linux】文件與目錄的默認權限與隱藏權限

01. 文件默認權限&#xff1a;umask文件的權限可以使用chmod來改變&#xff0c;但是我們默認創建文件的權限是什么&#xff1f;那就是與umask這個有關了。下來我們學習這個指令1.1 簡單使用umask[rootiZbp13q6hd8z3xaagcmz6gZ /]# umask0022[rootiZbp13q6hd8z3xaagcmz6gZ /]# u…

Servlet和JSP學習指導與實踐(二):Session追蹤

前言&#xff1a; web應用中經常需要對某些有用的信息進行存儲或者附加一些信息。本文主要介紹session&#xff0c;即“會話”跟蹤的幾種不同方式~ ----------------------------4種管理session的方式&#xff1a; 1.重寫url 通過在請求的url后面追加參數信息進行會話跟蹤。如&…

數據存儲和界面展示(二)

#測試 黑盒測試 測試邏輯業務 白盒測試 測試邏輯方法 根據測試粒度 方法測試&#xff1a;function test 單元測試&#xff1a;unit test 集成測試&#xff1a;integration test 系統測試&#xff1a;system test 根據測試暴力程度 冒煙測試&#xff1a;smoke test 壓力測…

linux在A目錄下創建B文件,Linux課程---5、常用文件命令和目錄命令(創建文件命令)...

Linux課程---5、常用文件命令和目錄命令(創建文件命令)一、總結一句話總結&#xff1a;touch file11、管道符|有什么用&#xff1f;將前一個命令的結果作為后一個命令的輸入&#xff1a;比如查看文件前3行&#xff1a;cat file1 | head -32、linux下如何復制粘貼命令是什么&…

window 系統上傳文件到linux 系統出現dos 格式換行符

Windows里的文件在Unix/Mac下打開的話&#xff0c;在每行的結尾可能會多出一個^M符號&#xff0c;Unix/Mac系統下的文件在Windows里打開的話&#xff0c;所有文字會變成一行&#xff0c;所以為了避免這種情況的發生&#xff0c;我們可以在linux系統內轉換格式 Centos系列可以直…

#pragma once與 #ifndef的區別

*************************************************** 更多精彩&#xff0c;歡迎進入&#xff1a;http://shop115376623.taobao.com *************************************************** 為了避免同一個文件被include多次 1 #ifndef方式2 #pragma once方式 在能夠支持這…

android學習者優秀網址推薦

非常漂亮的android UI庫集合&#xff0c;別人整理的&#xff0c;如果感覺不錯&#xff0c;趕快收藏吧&#xff01;&#xff01; https://github.com/wasabeef/awesome-android-ui https://github.com/Trinea/android-open-project android中文社區網 http://www.android-studio…

linux while read文件,linux shell腳本用while read逐行讀取文本的問題

問題:我現在是想用一個腳本獲取一定列表服務器的運行時間。首先我建立一個名字為ip.txt的IP列表(一個IP一行)&#xff0c;再建好密鑰實現不用密碼直接登錄。然后寫腳本如下&#xff1a;#!/bin/bashwhile read ips;doecho $ips;done < ip.txt腳本實現了逐行讀取列表中的IP&am…

常用字符串處理函數匯總

*************************************************** 更多精彩&#xff0c;歡迎進入&#xff1a;http://shop115376623.taobao.com *************************************************** (一)strcmp函數 strcmp函數是比較兩個字符串的大小,返回比較的結果。一般形式是&…

兼容性記錄-class屬性

getAttribute獲得class屬性時,IE6,IE7的傳參是className,IE7和現代游覽器都是class全部游覽器DOMElement均有的className屬性,其在IE各版本號下的均表現良好返回屬性class值的字符串此外html5中DOMElement有個classList屬性,它返回一個類型為DOMTokenList的對象,它當中有非常多…

magenta內核與linux,谷歌將推出新操作系統Fuchsia:Magenta語言為內核

谷歌現在研發出來并且推出使用的系統有Chrome OS、Android和Chromecasts&#xff0c;這三者在操作系統的市場中占得份額很高&#xff0c;但是好像谷歌對此并不滿意&#xff0c;因為有相關消息顯示&#xff0c;谷歌正在研發新的操作系統Fuchsia&#xff0c;該系統采用Magenta語言…

BZOJ 1968: [Ahoi2005]COMMON 約數研究 水題

1968: [Ahoi2005]COMMON 約數研究 Time Limit: 20 Sec Memory Limit: 256 MB 題目連接 http://www.lydsy.com/JudgeOnline/problem.php?id1968 Description Input 只有一行一個整數 N&#xff08;0 < N < 1000000&#xff09;。 Output 只有一行輸出&#xff0c;為整數M…

VC內存對齊準則(Memory alignment)

*************************************************** 更多精彩&#xff0c;歡迎進入&#xff1a;http://shop115376623.taobao.com *************************************************** 本文所有內容在建立在一個前提下&#xff1a;使用VC編譯器。著重點在于&#xff1a;VC…

[redis設計與實現][7]基本數據結構——對象

Redis對基礎數據類型進行了封裝&#xff0c;構建出上層的對象系統&#xff0c;這個系統包含&#xff1a;字符串對象、列表對象、哈希對象、集合對象和有序集合對象。 Redis對象結構&#xff1a; [cce lang”c”] typedef struct redisObject { //類型 unsigned type:4; //編碼 …