ç§ãã¡ã®ããŒã ã¯ããã¹ãŠã®Cããã³C ++éçºè ã®ããã«ãã¯ãªã¹ãã¹ããªãŒã®æ°ããã®ãã- æ°ããCLion 2017.3ãªãªãŒã¹ãæºåããŸããïŒ ãã®æçš¿ã§ã¯ã補åéçºã®ãããªãæ¹åæ§ãè©äŸ¡ãããããŠãã¡ãããã³ã¡ã³ãã®ãã¹ãŠã®è³ªåã«çããããã«ããããã©ãã»ã©è¯ãããäŒããããšããŸãã
ããŸãèªã¿ãããªã人ã®ããã®äž»ãªæ¹åç¹ã«ã€ããŠç°¡åã«èª¬æããŸãã
- C ++èšèªã®ãµããŒã
- ãªã¹ãã®åæåãååæ€çŽ¢ãªã©ã®ããŒãµãŒãµãã·ã¹ãã ã®æ¹å
- Microsoft Visual C ++ã³ã³ãã€ã©åºæã®æ¡åŒµæ©èœã®ãµããŒã
- __COUNTER__ãã¯ãã®ãµããŒã
- ãããŠããã ãã§ã¯ãããŸããïŒ
- æ°ããããŒã«ãšãã¬ãŒã ã¯ãŒã¯
- Valgrind memcheck
- ããŒã¹ããã¹ã
- CMake 3.9ãGDB 8.0ãLLDB 5.0
- ã³ã³ãã€ã©ãç°å¢ãCMakeããããã¬ãªã©ãæ§æããããã®å®è³ªçãªåŠçãšæ¡åŒµæ©èœ
- ã»ãŒä»»æã®ã¡ã€ã³æ©èœãã¡ã€ã³æ©èœããã³ãã¹ããèµ·åããããã®ã¢ã€ã³ã³ãèµ·åããæ©èœ
- Kotlin / CLionã®ãã€ãã£ãã§éçºããèœå
ããã§ãç¡æã®30æ¥éããŒãžã§ã³ãWebãµã€ãããããŠã³ããŒãããŠãæ°ããæ©èœãè©Šãããšãã§ããŸãïŒãã®ããã«ãç¹å¥ãªå°ããªãã¢ãããžã§ã¯ããçšæããŸããïŒã 以äžã§ã¯ãæ¹åç¹ã«ã€ããŠããã«è©³ãã説æããŸãã
C ++èšèªã®ãµããŒã
ã°ããŒãã«ãªæ¹å
ããããã»ãšãã©ã®äººã¯ãC ++çšã®ç¬èªã®ããŒãµãŒãäœæããŠããããšãç¥ã£ãŠããã§ãããã ããã«ããããŠãŒã¶ãŒéïŒãã®è°è«ã¯Habréãredditãªã©ã«é¢ããããã§ã®æçš¿ã®ããããã§çºçããŸãïŒãšããŒã å ã§ãããŸããŸãªè°è«ãåŒãèµ·ãããŸãã ããã«èå³æ·±ãã®ã¯ãçŸåšã®ãœãªã¥ãŒã·ã§ã³ãæ¹åããå¯èœãªä»£æ¿ãªãã·ã§ã³ãèããããšã§ãïŒãšããã§ãå®å šã«é€å€ããããã§ã¯ãããŸããïŒïŒã ãããŠæè¿ãç§ãã¡ã¯ãœãªã¥ãŒã·ã§ã³ãã°ããŒãã«ã«åèšèšããããšã決å®ããŸãããäžçªäžã«ãããµãã·ã¹ãã ããå§ããŠãåŸã ã«äžæããŸãã ããŒãžã§ã³CLion 2017.3ã¯ã ãªã¹ãã®åæåãšååæ€çŽ¢ã«åœ±é¿ããŸããã
ãªã¹ãã®åæåã®å Žåãä¿®æ£ã«ãããåºæ¬çã«CLionã¯ãåŒæ°ãå€ãããŸãã ã ãåŒæ°ãå°ãªãããŸãã ã ãäžèŽããã³ã³ã¹ãã©ã¯ã¿ããããŸãã ããªã©ã®èª€ã£ãèŠåã衚瀺ããªããªããŸããã ãããŠãããã©ããããä»ã§ã¯ãããå¿ èŠãªå Žæã瀺ããŠããŸãïŒ
ããã«ãCLionã¯åäžãªåæåã®å Žåã«å€æ°ãæ£ããç解ã§ããããã«ãªããŸããã
ãã®ãªãªãŒã¹ã§ä¿®æ£ããããã1ã€ã®åéã¯ã ååæ€çŽ¢ã§ãã å€æ°åãšãã®å®£èšãæ£ããé¢é£ä»ããããšã¯ãèšèªãµããŒãã®åºæ¬çãªã¿ã¹ã¯ã®1ã€ã§ãã ãã®æ®µéã§ã®åé¡ã¯ãäžæ£ãªã³ãŒãã¢ãã©ã€ã¶ãŒã¡ãã»ãŒãžãäžæ£ãªã³ãŒãçæãªã©ã«ã€ãªãããŸããäž»ãªä¿®æ£ã¯ã
using
ã³ã³ã¹ãã©ã¯ããŸãã¯usingã¿ã€ãç¶æ¿
using
ããŠã¹ã³ãŒãã«æž¡ãããå€æ°ã®æ£ãã解決é åºãšè§£æ±ºã«é¢é£ããŠããŸããã
MSVCæ¡åŒµæ©èœã®ãµããŒã
ãã·ã³ã«Microsoft Visual C ++ã³ã³ãã€ã©ãã€ã³ã¹ããŒã«ãããŠããå ŽåãCLionã§å®éšçãªMSVCãµããŒããæå¹ã«ããGCCããã³Clangã®ä»£ããã«ãã®ã³ã³ãã€ã©ã䜿çšã§ããŸãã å®éšçãµããŒãã«ã¯ãããã€ãã®çç±ã§ååãä»ããããŠããŸãã
- åœåãCLionã¯ç¹å¥ãªC ++ MSVCæ¡åŒµæ©èœããµããŒãããŠããŸããã§ããã
- CLion for MSVCã§å©çšå¯èœãªãããã¬ã¯ãããŸãã
CLion 2017.3ã«ã¯ãæåã®ã¢ã€ãã ã®ä¿®æ£ãå«ãŸããŠããŸãã ãµããŒããããŠããæ¡åŒµæ©èœã¯ã
__unaligned
__uuidof
ã
__unaligned
/
__alignof
ã
__ptr32
/
64
ãªã©ã§ãã å®å šãªãªã¹ãã¯ã ããã°ã§å ¥æã§ããŸãã
æ®å¿µãªãããMSVCã®ãããã¬ãŒã«é¢ããå ·äœçãªèšç»ã¯ãŸã ãããŸããïŒãã ããMSVCã®ããŸããŸãªãããã¬ãŒãšãã®ã©ã€ã»ã³ã¹ã®ãããã¯ã«é¢ããèå³æ·±ãè°è«ããããŸãïŒã
C ++ãµããŒãã®ãã®ä»ã®äŸ¿å©ãªæ¹å
CLionã®èšèªãµããŒãããŒã ã¯æé·ããŠããŸãïŒ ãããã£ãŠããã©ãã«ãŒããã®ããéèŠãªãªã¯ãšã¹ããåŸã ã«ã«ããŒããŠããŸãã ãã®ãªãªãŒã¹ã§ã¯ã圌ãã¯ãŸã 次ã®ããšãã§ããŸããã
- ãã¯ããµããŒã__COUNTER__ ã ãã®å€ã¯çŸåšãæ£çŽã«èšç®ãããŠããŸããã€ãŸããCLionã¯ãããšãã°ã ãéè€å®£èšãã«é¢ãã誀ã£ãèŠåã衚瀺ããªããªããŸãã ãŸããã¯ã€ãã¯ããã¥ã¡ã³ããŠã£ã³ããŠïŒLinux / Windowsã§ã¯Ctrl + QãmacOSã§ã¯F1ïŒã§ããã¯ã眮æã®çµæã確èªã§ããŸãã
- é¢æ°ã®å®çŸ©çæïŒLinux / Windowsã§ã¯Shift + Ctrl + DãmacOSã§ã¯â§âDïŒã¯ãé¢æ°ãã³ãã¬ãŒãã®å Žåã«æ£ããæ©èœããããã«ãªããŸããã
- 人æ°ã®ãªãã¡ã¯ã¿ãªã³ã°ãã³ãã¬ãŒãã®ãµããŒããè¿œå ãããŸãã-if
if-else
ãããã¯ã®å転ã ãã®ãã¿ãŒã³ã¯ãå€ãã®ãã¹ããããifãããã¯ã䜿çšããã³ãŒããç°¡çŽ åããããã«ãã䜿çšãããŸãã
ãªãŒãã£ãªã¢ããªã±ãŒã·ã§ã³éçºè åã
ãŸãããã«ããã©ãããã©ãŒã ãªãŒãã£ãªã¢ããªã±ãŒã·ã§ã³ãéçºãã人ãã¡ã®æ¹åç¹ã«ã€ããŠã話ããããšæããŸãã ãã®ãããªéçºã®ããã«ãéåžžã«ããç¥ãããŠããC ++ã©ã€ãã©ãªJUCEããããŸãã CLion 2017.3ã§ã¯ãJUCEã®äœ¿çšæã«çºçããããã€ãã®èšèªãµããŒãã®åé¡ãä¿®æ£ããŸããã
ããããJUCEãŠãŒã¶ãŒã«ãšã£ãŠã®äž»ãªãã¥ãŒã¹ã¯JUCE 5.2ã®ãªãªãŒã¹ã§ãProjucerã®æ°ããããŒãžã§ã³ã¯ãããžã§ã¯ããCMakeã«ãšã¯ã¹ããŒãããæ©èœãè¿œå ããŸããã ãããŠãããã¯CLionã§ã®ãããªãéçºã®ããã«ãããéãããšãæå³ããŸãïŒ ãªãŒãã£ãªãã©ã°ã€ã³ã®ãã¢ãäœæããCMakeã«ãšã¯ã¹ããŒãããCLionã§éããAbleton Liveã§ãã©ã°ã€ã³ãå®è¡ããCLionã§ãããã°ããçããã¢ãèšé²ããŸããã
Valgrind Memcheckãšã®çµ±å
ãã©ãã«ãŒã§æã人æ°ã®ãããªã¯ãšã¹ãã®1ã€ã¯ããããã¡ã€ãªã³ã°ããŒã«ãç¹ã«Valgrindãšã®çµ±åã§ãã ãã®ãªãªãŒã¹ã§ã¯ãæãéèŠãªãã®ããå§ããŸãã-Valgrind Memcheckã䜿çšããŠã¡ã¢ãªã®ãããã¡ã€ã«ãäœæããæ©èœãè¿œå ããŸããã
ãã®ã¿ã¹ã¯ã§ãã䜿çšãããGoogle Sanitizersãšã¯ç°ãªããValgrind Memcheckã¯å€ãã®ãã©ãããã©ãŒã ããµããŒãããŠããŸãïŒãã ããæ®å¿µãªãããSanitizersãšåæ§ã«ãWindowsã§ã¯äœ¿çšã§ããŸããïŒã ããã°ã©ã ãåã³ã³ãã€ã«ããå¿ èŠã¯ãªããClangãšGCCã®äž¡æ¹ã䜿çšããŠã³ã³ãã€ã«ãããå®è¡å¯èœãã¡ã€ã«ã§åäœããŸãã ããã«ããã®ããŒã«ã䜿çšãããšãã¡ã¢ãªãæäœããéã®ããŸããŸãªåé¡ãç¹å®ã§ããŸãã
- ã¡ã¢ãªãªãŒã¯
- ããšãã°ãfreeãåŒã³åºããåŸã®äžæ£ãªã¡ã¢ãªã¢ã¯ã»ã¹
- ã¡ã¢ãªå²ãåœãŠãšå²ãåœãŠè§£é€æäœã®äžäžèŽïŒmalloc / freeãnew / deleteïŒ
- åæåãããŠããªãå€æ°ã䜿çšãã
- 亀差ããã¡ã¢ãªé åãmemcpyåé¢æ°ã®é¢æ°ãšããŠæž¡ã
- è² ã®ãµã€ãºãªã©ãééã£ããµã€ãºã®ã¡ã¢ãªãå²ãåœãŠãæ©èœãæž¡ã
CLionã§ã¯ãValgrind Memcheckã䜿çšããŠæ§æãå®è¡ã§ããèµ·åçµæãŠã£ã³ããŠã§ãåé¡ã«å¯Ÿå¿ããã¹ã¿ãã¯ã®äžéšããåé¡ãçºçããã³ãŒãå ã®å Žæã®ãã¬ãã¥ãŒãªã©ãæœåšçãªåé¡ã«é¢ããæ å ±ãååŸã§ããŸãã èšå®ã䜿çšãããšãããããæå¶ãã¡ã€ã«ïŒã©ã€ãã©ãªã§ã®åæãç¡å¹ã«ããå Žåãªã©ïŒãšValgrind Memcheckãèµ·åããããã®ãªãã·ã§ã³ãæå®ã§ããŸãã
åäœãã¹ãã®æ©èœåŒ·å
CLionã§ã®åäœãã¹ãã®ãã¬ãŒã ã¯ãŒã¯ãšã®çµ±åã«ã¯ãçµæã®åºåïŒãã¹ãã©ã³ããŒïŒãåããçµã¿èŸŒã¿ãŠã£ã³ããŠã§ã®ãã¹ãã®å®è¡ãå«ãŸããŸãã Google Test and Catchã以åã«ãµããŒããããŠããå Žåãä»ã§ãBoost.Testãè¿œå ãããŸãã
ã¡ãªã¿ã«ãå·ŠåŽã®åïŒãgatterãïŒã«ã¯ãæ°ããã¢ã€ã³ã³ããããŸãã ãµããŒããããŠãã3ã€ã®ãã¬ãŒã ã¯ãŒã¯ãã¹ãŠã§æ©èœãããã¹ãã®å®è¡ã«åœ¹ç«ã¡ãŸã-ããããã¯ãªãã¯ãããšãValgrind Memcheckã§å®è¡ããããã°ããŸãã¯å®è¡ãéžæã§ããŸãã ãŸããæåã®ãã¹ãå®è¡åŸãã¢ã€ã³ã³ã®å€èŠ³ãå€ããããã¹ãã®ã¹ããŒã¿ã¹ïŒåæ ŒãŸãã¯äžåæ ŒïŒã®è¡šç€ºãéå§ãããŸãã æè¿èµ·åãããã¹ãã§ãã¡ã€ã«ãéããäœãã©ã®ããã«ãã°ããç解ãããå Žåã«éåžžã«äŸ¿å©ã§ãã
åæ§ã«ãå·Šã®ã¬ã¿ãŒã®ã¢ã€ã³ã³ã䜿çšããŠãCMakeã¿ãŒã²ãããããã¡ã€ã³é¢æ°ãå®è¡ã§ããŸãïŒã¿ãŒã²ãããªãã§ã¯ãäœãã©ã®ããã«å®è¡ããããæ£ç¢ºã«ç解ããããšã¯éåžžã«å°é£ã§ãïŒã ãã ããå®è¡æ§æã¯äœæããå¿ èŠã¯ãããŸãã-ã¢ã€ã³ã³ãã¯ãªãã¯ãããšãCLionã¯èªåçã«äœæããŸãã
ããŒã«ãã§ãŒã³ãã³ã³ãã€ã©ãCMakeã®èšå®
CMakeã®åéã§ã®ã»ãŒäŒçµ±çãªç§ã®å€æŽãããã³ããŒã«ãã§ãŒã³ãšèšå®ã®èšå®ã¯ããã®ãªãªãŒã¹ã§ã¯ééããŸããã§ããã äž»ãªãã®ïŒ
- IDEã§è€æ°ã®ããŒã«ãã§ãŒã³ãæ§æããåãããžã§ã¯ãã«å¿
èŠãªããŒã«ãã§ãŒã³ãéžæããããåããããžã§ã¯ãã®ç°ãªãã¿ãŒã²ããã«è€æ°ã®ç°ãªãããŒã«ãã§ãŒã³ã䜿çšããããšãã§ããŸãã ããã¯ç¹ã«ãCygwin / MinGW / MSVCç°å¢ãç°¡åãã€è¿
éã«åãæ¿ãããWindowsã®ãŠãŒã¶ãŒã«åœãŠã¯ãŸããŸãã
- Makeãšåæ§ã«ãCã³ã³ãã€ã©ãšC ++ã³ã³ãã€ã©ãç°¡åã«åãæ¿ããããšãã§ããããã«ãªããŸããã ããã¯ãäžèšã®ããŒã«ãã§ãŒã³èšå®ã§è¡ãããšãã§ããŸãã
- ããã§ãåããã«ãã¿ã€ãïŒãããã°ããªãªãŒã¹ãªã©ïŒã§è€æ°ã®CMakeãããã¡ã€ã«ãäœæã§ããŸãããç°ãªããªãã·ã§ã³ãããŒã«ãã§ãŒã³ïŒã³ã³ãã€ã©ãªã©ïŒã§äœ¿çšãããç°å¢èšå®ãªã©ããããŸãã
- CMakeãããã¡ã€ã«ã¯ãéå§ãããå®è¡/ãããã°æ§æã«çŽæ¥é¢é£ããªããªããŸããããåå¥ã«éžæãããŸãã
ãããã¬ãŒãšCMakeã®æ°ããããŒãžã§ã³
CLion 2017.3ã«ã¯ã次ã®ããŒã«ã®æŽæ°ããŒãžã§ã³ãå«ãŸããŠããŸãã
- CMakeã3.9ã«æŽæ°ãããŸãã
- GDBã8.0ã«æŽæ°
- LLDBã5.0ã«æŽæ°
CLionã«ä»å±ããGDB 8.0ã¯ãããã€ãã®ã¢ãŒããã¯ãã£ããµããŒãããŠæ§ç¯ãããŠããããšã«æ³šæããŠãã ããã ã€ãŸããç°ãªããã©ãããã©ãŒã éïŒWindowsããLinuxãªã©ïŒã§ã®ãªã¢ãŒããããã°ã䜿çšãããšãGDBãåæ§ç¯ããå¿ èŠã¯ãªããªããŸãããçµã¿èŸŒã¿ã䜿çšã§ããŸãã
ã³ããªã³/ãã€ãã£ã
JetBrainsãæ°ããããã°ã©ãã³ã°èšèªã§ããKotlinãäœæããç©æ¥µçã«éçºããŠããããšããåãã®æ¹ã¯ãåç¥ã§ããããä»å¹ŽãGoogle I / Oã§Androidã¢ããªã±ãŒã·ã§ã³ãéçºããããã®èšèªãšããŠå ¬åŒã«èªããããŸãã ã ãŸããiOSãLinuxãWindowsãmacOSãWebAssemblyãªã©ã®ãã©ãããã©ãŒã çšã®ãã·ã³ã³ãŒãã«KotlinãçŽæ¥ã³ã³ãã€ã«ã§ããKotlin / Nativeãããžã§ã¯ãããããŸãã
Cããã³C ++ã§ã®ã¯ãã¹ãã©ãããã©ãŒã éçºçšã®IDEã§ããCLionã¯ã©ãã«ãããŸããïŒ å®éãKotlin / Nativeã¯ãClangãLLDBãªã©ããã€ãã£ãéçºã®äžçã®ãã¯ãããžãŒãšçµ±åãããŠããŸãã ãããŠãCLionã¯ããã€ãã£ãéçºã®IDEã§ãããšèŠãªãããŠããŸãããã®èšèªã§ã¯ãCããã³C ++ãäž»èŠèšèªãšããŠãPythonãSwiftãRustãè¿œå èšèªãšããŠãµããŒããããŠããŸãïŒãããŸã§ã¯ãã¹ãŠCMakeã®ãã¬ãŒã ã¯ãŒã¯å ïŒã ãããã£ãŠãéçºçšã®ãã©ã°ã€ã³ããªãªãŒã¹ããã®ã¯åœç¶ã®ããšã§ãç¹ã«CLionåãã«Kotlin / Nativeã§éçºããŸããã 詳现ã«ã€ããŠã¯ãKotlinããã°ãã芧ãã ããã ãããŠå°æ¥ãä»ã®ããŒã«ã«Kotlin / Nativeãç»å ŽããããšãæåŸ ã§ããŸãã
ããã§ãCLion 2017.3ã®æ°æ©èœã®æŠèŠã§çµãããŸãã ãã¡ãããIntelliJãã©ãããã©ãŒã ããæ¥ãããŒãžã§ã³ç®¡çã·ã¹ãã ãšä»ã®æ©èœããµããŒãããã¢ããããŒãããããŸãã ããããç§ã¯èªåèªèº«ãç¹°ãè¿ããã ããHabrã®IntelliJ IDEA 2017.3ã«é¢ããããã°æçš¿ãåç §ããŸãã
éçºè åŒè·å£«ã«ããè±èªã®CLion 2017.3ã®æ°æ©èœã®ãã¢ïŒ
èå³ã®ããæ¹ã¯ãäŒç€Ÿã®å ¬åŒãŠã§ããµã€ããã30æ¥éã®ç¡æãã©ã€ã¢ã«ãããŠã³ããŒãããŠãã ããã äŸ¡æ Œã»ã¯ã·ã§ã³ã§ãµãã¹ã¯ãªãã·ã§ã³ã®ã³ã¹ãã«ã€ããŠã確èªã§ããŸãã
è±èªã®ããã°ã®èšäºãšæŽæ°ãã楜ãã¿ã«ã ã³ã¡ã³ãã§ã質åã«ãçãããŸãã
JetBrains CLionããŒã
éçºãžã®æ欲