VCã®ã³ã³ãã¤ã«è¨å®ãªã©ï¼Cå¦ç¿ä¸ï¼
ãCode Readingã第2ç« ãèªãã ãåãã¦åãããããã¤ã¤ãè¦ãããã¨ã¨ãã¯ã«ã©ã³ãã¨ã¨ãã¡ã¢ãç°å¢ï¼Visual C++ 2010 Express
__Pãã¯ãã®æå³
Pãã¯ãã¯ãANSI以åã®ã³ã³ãã¤ã©åãã®é¢æ°å®£è¨ã
èªãã§ãã®ãNetBSDã®ã³ã¼ãã ããåºã¦ãããã©ãåºæ¬çã«ã¯ææ¥ããã¤ã¤ããè¨è¿°ã ã¨èªèãã¦ããã°ããã®ããªã»ã»ã»ã
VCã®ã³ã³ãã¤ã«è¨å®
ã³ã³ãã¤ã«ã®è¦åã¬ãã«ã¯ãããã¸ã§ã¯ãé¸æâï¼»ããããã£ï¼½âï¼»æ§æããããã£ï¼½âï¼»C/C++ï¼½âï¼»å ¨è¬ï¼½ã§å¤æ´ã§ããï¼ããã©ã«ãã¯Level3ï¼ãLevel4以ä¸ã«ãã¦ããã°ãä¸åº¦ãåç §ãã¦ããªãå¤æ°ãè¦åãã¦ãããããã ãåæåãã¦ããªãå¤æ°ãè¦åãã¦ãããæ¹æ³ãåãããªãï¼ããã®ããªï¼ï¼ã
ä»»æã®ã³ã³ãã¤ã«ãªãã·ã§ã³ã追å ããããã°ãï¼»C/C++ï¼½âï¼»ã³ãã³ãã©ã¤ã³ï¼½ã«æ¬¡ã®ãªãã·ã§ã³ãæ¸ããã
ä¸è¨ã¯ãGCCã¨VCã®ã³ã³ãã¤ã©ã®æ¯è¼ãã¾ã¨ãããã¦ããç´ æ´ããããã¼ã¸ã
unistd.hã®getoptãVCã§ä½¿ãããã¨ã
getopté¢æ°ã¯ãunistd.hã§å®ç¾©ããã¦ãããunistd.hã¯Windowsç°å¢ã®VCã«åå¨ããªããããincludeãããã¨ããã¨ã¨ã©ã¼ã«ãªããunistd.hã®ä¸é¨ã®é¢æ°ã¯VCã«ãããä»ã®ããããã¡ã¤ã«ï¼io.hãªã©ï¼ã§å®ç¾©ããã¦ããã®ã§ã代ããã«ãããã使ã£ã¦æ¸ãã°ããããããgetoptã¯ãªãã
ã¨ããããã§ã次ã®æ¹æ³ã§ãã«ããã¦ä½¿ç¨ããã
- ä»»æã®ãã©ã«ãã«getopt.cã¨getopt.hãå
¥ããã
- ãµã³ãã«ã³ã¼ãï¼http://www.pwilson.net/sample.html
- ããã¸ã§ã¯ãé¸æâï¼»ããããã£ï¼½âï¼»æ§æããããã£ï¼½âï¼»C/C++ï¼½âï¼»å ¨è¬ï¼½ã§ã[追å ã®ã¤ã³ã¯ã«ã¼ã ãã£ã¬ã¯ããªï¼½ã«ãã©ã«ããæå®ããã
- ããã¸ã§ã¯ãé¸æâï¼»æ¢åé ç®ã®è¿½å ï¼½ãããgetopt.cã追å ããã
æ¢åé ç®ã®è¿½å ã§ãããã¸ã§ã¯ãã«ããããã¡ã¤ã«ã追å ãããã¨ãã§ããããã³ã³ãã¤ã«ã¨ã©ã¼ãfatal error C1083: include ãã¡ã¤ã«ãéãã¾ããããåºãããªã®ã§ãã³ã³ãã¤ã«ãªãã·ã§ã³ï¼/Iï¼ã§ã¤ã³ã¯ã«ã¼ããã£ã¬ã¯ããªãæå®ãããï¼ä¸è¨2ï¼
ã¾ããã¤ã³ã¯ã«ã¼ããã£ã¬ã¯ããªãæå®ããã ãã®ç¶æ ã ã¨ãã³ã¼ãåä½ã§ã®ã³ã³ãã¤ã«ã¯ã§ããããããã¸ã§ã¯ãã®ãã«ãã§ã¨ã©ã¼ã«ãªãããerror LNK2001: å¤é¨ã·ã³ãã« "_optind" ã¯æªè§£æ±ºã§ãããerror LNK2019: æªè§£æ±ºã®å¤é¨ã·ã³ãã« _getopt ãé¢æ° _main ã§åç §ããã¾ããããªã©ãããã¯ãã³ã¼ãã®å®ä½ããªãã¦ãå¤é¨åç §æ å ±ãVCã®objãã¡ã¤ã«ã«æ¸ãè¾¼ã¾ãã¦ã³ã³ãã¤ã«ã¾ã§ã¯ã§ãããã®ã®ããã«ãããæã«ãªã³ã¯ã«å¤±æãã¦ãããã¨ããç¶æ ãããããªã®ã§ãã½ã¼ã¹ãã¡ã¤ã«ãããã¸ã§ã¯ãã«è¿½å ãããï¼ä¸è¨3ï¼
# åå¿è ãå°ããã¤ã³ãããããæ¤ç´¢ããã¨è²ã ã§ã¦ããããã©ãçµå±ã©ãããã®ãæ£ããã®ãåãããªãããã