Построение систем автоматического протоколирования Си/Си++ кода

  • Published on
    17-Dec-2014

  • View
    315

  • Download
    8

Embed Size (px)

DESCRIPTION

. () , . , /++.

Transcript

<ul><li> 1. /++ : : 13.05.2008 . () , . , /++. , ++ . 10 - . , - ++. , , . , , " " [1] comp.lang.c++.moderated"Why do you program in c++?" [2]. , /++ . , /++ . , , . , . : ; Runtime-; () ; (Unit Testing); ; ; -; (Code Review); .</li></ul> <p> 2. , " " [3]. () .1. ? . , ? , , , . , : 1. (Release) . Release Debug, .. Release . , , , Release . . 2. . (, Hasp) , . , , . 3. - , . , . 4. . 5. . 6. (diff) . , . 7. , . , , . , . 8. . . . , , [1]. 3. , . , , .2. , : , , . -, . -, . , , Debug Release . , . , . . , , . . , , , . . , , , [4]. , , - . , , , . , , . , "Logging In C++" [5] " : " [6]. , , . , printf, :int x = 5, y = 10;...printf("Coordinate = (%d, %d)n", x, y); 4. , , . , :#ifdef DEBUG_MODE#define WriteLog printf#else#define WriteLog(a)#endifWriteLog("Coordinate = (%d, %d)n", x, y); . , WriteLog _DEBUG, DEBUG_MODE. Release-, . , , , Visual C++ : "warning C4002: too many actual parameters for macro WriteLog". , . , :#ifdef DEBUG_MODE#define WriteLog(a) printf a#else#define WriteLog(a)#endifWriteLog(("Coordinate = (%d, %d)n", x, y)); , , . :#ifdef DEBUG_MODE#define WriteLog printf#elseinline int StubElepsisFunctionForLog(...) { return 0; }static class StubClassForLog {public: inline void operator =(size_t) {}private: inline StubClassForLog &amp;operator =(const StubClassForLog &amp;) 5. { return *this; }} StubForLogObject;#define WriteLog StubForLogObject = sizeof StubElepsisFunctionForLog#endifWriteLog("Coordinate = (%d, %d)n", x, y); , . DEBUG_MODE , . . , :enum E_LogVerbose {Main,Full};#ifdef DEBUG_MODEvoid WriteLog(E_LogVerbose,const char *strFormat, ...){...}#else...#endifWriteLog (Full, "Coordinate = (%d, %d)n", x, y); , , , . , , , , . WriteLogMain, WriteLogFull , . 6. , . , , . () . N1. 7. N1. . , . . . . , 5000 4000 . 20 , , . , . WriteLog. , . , , . (thread), , ( N2). 8. N2. . , , . , , N3. , , . 9. N3. . , , . , , , - . , , . . 10. :class NewLevel {public:NewLevel() { WriteLog("__BEGIN_LEVEL__n"); }~NewLevel() { WriteLog("__END_LEVEL__n"); }};#define NEW_LEVEL NewLevel tempLevelObject;void MyFoo() {WriteLog("Begin MyFoo()n");NEW_LEVEL;int x = 5, y = 10;printf("Coordinate = (%d, %d)n", x, y);WriteLog("Begin Loop:n");for (unsigned i = 0; i != 3; ++i){NEW_LEVEL;WriteLog("i=%un", i);}} :Begin MyFoo()__BEGIN_LEVEL__Coordinate = (5, 10)Begin Loop:__BEGIN_LEVEL__i=0__END_LEVEL____BEGIN_LEVEL__i=1__END_LEVEL__ 11. __BEGIN_LEVEL__i=2__END_LEVEL__Coordinate = (5, 10)__END_LEVEL__ :Begin MyFoo()Coordinate = (5, 10)Begin Loop:i=0i=1i=2Coordinate = (5, 10)3. , . , . . : 1. , . ++ . 2. NEW_LEVEL , , . 3. . . 4. , , NEW_LEVEL. 5. , , . 6. , "#include" . , . , /++ . 12. - , [7]. : . . , - , . , . , . Nemerle, " Nemerle" [8]. /++ , : 1. ++ . , , . 2. . , . . . /++ , . . , :EnableLogFunctionCallForFhisFile(true);...ObjectsArray &amp;objects = getObjects();WriteLog("objects.size = %u", objects.size());for (size_t i = 0; i != objects.size(); ++i) {WriteLog("object type = %i", int(objects [i]-&gt;getType()));if (objects[i]-&gt;getType() != TYPE_1)... , . .ObjectsArray &amp;objects = getObjects();MyLog "objects.size = ", objects.size()for (size_t i = 0; i != objects.size(); ++i) {MyLog "object type = ", int(objects [i]-&gt;getType())if (objects[i]-&gt;getType() != TYPE_1) 13. ... , :thisfile.log.FunctionCall = ON...ObjectsArray &amp;objects = getObjects();for (size_t i = 0;i != "objects.size = "objects.size();++i) {LOG: "object type = " {as int} objects [i]-&gt;getType();if (objects[i]-&gt;getType() != TYPE_1) ... . . , N4. 14. 4. . . N5. 15. 5. . . . -, , . . -, . - . , , . , ., , : 1. , ++. . , , ++ . 2. . NEW_LEVEL. 3. . . 4. . 5. , . , . 6. , "#include" , . . , , . - , . , ( ) . , . . , OpenMP, "#pragma". :ObjectsArray &amp;objects = getObjects();#pragma Log("objects.size = ", objects.size())for (size_t i = 0; i != objects.size(); ++i) { 16. #pragma Log("object type = ", objects [i]-&gt;getType()) if (objects[i]-&gt;getType() != TYPE_1) ... - "#pragma", . , . . .4. , , , . , , , , . , /++. . , , . , . , , . OpenC++ (OpenCxx) [9]. "source-to-source" . ++. OpenTS T++ ( ) Synopsis . VivaCore, OpenC++, Microsoft Visual Studio 2005/2008 [10]. . ++. Viva64 VivaMP. , , . , . , The Wave C++ preprocessor library. 17. , , .! 1. Casual Games Association. . http://www.viva64.com/go.php?url=342. Over at comp.lang.c++.moderated, there is a thread created by the c++ guru Scott Meyers on the subject: "Why do you program in c++?" http://www.viva64.com/go.php?url=353. . . http://www.viva64.com/go.php?url=364. , . Visual C++. http://www.viva64.com/art-1-1-640027853.html5. Petru Marginean. Logging In C++. http://www.viva64.com/go.php?url=376. . : . http://www.viva64.com/go.php?url=387. . , 1: . http://www.viva64.com/go.php?url=398. Kamil Skalski. Nemerle. http://www.viva64.com/go.php?url=409. Grzegorz Jakack. OpenC++ - A C++ Metacompiler and Introspection Library. http://www.viva64.com/go.php?url=4110. , . VivaCore. http://www.viva64.com/art-2-1-696420215.html , ..-.., "", . . VivaCore Viva64, VivaMP. : http://a-karpov.moikrug.ruE-Mail: karpov@viva64.com </p>