small medium large xlarge

Generic-user-small
07 Nov 2014, 10:30
Arnd R.Strube (88 posts)

Seems like I jumped the gun here ;-). Since I consider it a great waste of time to get, build, and integrate any third party libraries, and my main goal is to work through the book, I stubbed the rLog stuff upfront. The result is extremely simple and consists of three headers.

(I realize that, if you were working on the legacy code, you would probably have everything in place already, so the approach mentioned in chapter 8 is actually very helpful for that situation).

So, here goes:

Generic-user-small
07 Nov 2014, 11:20
Arnd R.Strube (88 posts)

RLogChannel.h:

#pragma once

namespace rlog
{
    #define RLOG_CHANNEL(string) NULL

    class RLogChannel {};

} // namespace rlog
Generic-user-small
07 Nov 2014, 11:30
Arnd R.Strube (88 posts)

StdioNode.h:

pragma once

namespace rlog
{
    class RLogNode;
    class StdioNode {
    public:
        StdioNode(int) {}
        void subscribeTo(RLogNode*) {}
    };
} // namespace rlog
Generic-user-small
07 Nov 2014, 11:23
Arnd R.Strube (88 posts)

rlog.h:

#pragma once

namespace rlog
{
    class RLogChannel;

    #define DEF_CHANNEL(string, level) (RLogChannel*)0

    void rLog(RLogChannel*, const char *, ...) {}

} // namespace rlog
Generic-user-small
07 Nov 2014, 11:27
Arnd R.Strube (88 posts)

The way I arrived at this is by incrementally supplying the least possible code to fix compiler errors, and subsequently linker errors, until they were all gone.

For instance, when a RLogChannel* was required, initially I just supplied a forward declaraion.

Later, when the linker complained, I added an empty class definition.

You must be logged in to comment