I've been working with the InspIRCd group to try to get it working on
OpenBSD again.  The server I'm doing this on is OpenBSD 4.2 on an
Alphaserver 1000 4/200.

There is a header which has the following section:

#ifdef __GNUC__
#define CUSTOM_PRINTF(STRING, FIRST) __attribute__((format(printf, STRING,
FIRST)))
#else
#define CUSTOM_PRINTF(STRING, FIRST)
#endif


There is a .cpp file which includes that header and contains the following
function definition:

        void WriteCommonFrom(User *user, Channel* channel, const char* text,
...) CUSTOM_PRINTF(4,5)
        {
                va_list argsPtr;
                char textbuffer[MAXBUF];
                char tb[MAXBUF];

                va_start(argsPtr, text);
                vsnprintf(textbuffer, MAXBUF, text, argsPtr);
                va_end(argsPtr);
                snprintf(tb,MAXBUF,":%s %s",user->GetFullHost().c_str(),
textbuffer);
                CUList *ulist = channel->GetUsers();

                for (CUList::iterator i = ulist->begin(); i != ulist->end();
i++)
                {
                        /* User doesnt get a JOIN sent to themselves */
                        if (user == i->first)
                                continue;

                        /* Users with a visibility state that hides them
dont appear */
                        if (user->Visibility &&
!user->Visibility->VisibleTo(i->first))
                                continue;

                        i->first->Write(std::string(tb));
                }
        }



When the make process attempts to build this, it has the following errors:

        BUILD:              m_delayjoin.cpp
An error occured when executing: g++ -pipe -I../../include -fPIC
-Woverloaded-vi
rtual -Wshadow -Wformat=2 -Wmissing-format-attribute -Wall -g1 -pedantic
-fPIC -
DPIC -shared -export-dynamic -o m_delayjoin.so m_delayjoin.cpp
m_delayjoin.cpp:197: error: syntax error before `{' token
m_delayjoin.cpp:202: error: `argsPtr' was not declared in this scope
m_delayjoin.cpp:202: error: `text' was not declared in this scope
m_delayjoin.cpp:202: error: invalid data member initialization
m_delayjoin.cpp:202: error: (use `=' to initialize static data members)
m_delayjoin.cpp:202: error: ISO C++ forbids declaration of `
   __builtin_stdarg_start' with no type
m_delayjoin.cpp:203: error: invalid use of member
`ModuleDelayJoin::textbuffer'
m_delayjoin.cpp:203: error: `text' was not declared in this scope
m_delayjoin.cpp:203: error: `argsPtr' was not declared in this scope
m_delayjoin.cpp:203: error: invalid data member initialization
... SNIP ...

Line 197 is the line that calls CUSTOM_PRINTF.  If the CUSTOM_PRINTF portion
is removed, the module compiles.
Is there a different format expected for __attribute__ that should be looked
at?

I've never used __attribute__ before, nor have I used variable length
parameters as this function is doing, so any
help pointing me in the right direction would be nice.  All of the
documentation I've been able to find on the subject
seems to indication this should work, but it fails.

With CUSTOM_PRINTF removed, the output generates this warning:

m_delayjoin.cpp: In member function `void
   ModuleDelayJoin::WriteCommonFrom(User*, Channel*, const char*, ...)':
m_delayjoin.cpp:203: warning: function might be possible candidate for
`printf'
   format attribute
m_delayjoin.cpp:203: warning: function might be possible candidate for
`printf'
   format attribute

I tried changing CUSTOM_PRINTF(4, 5) to CUSTOM_PRINTF(3, 4) because it
looked like it was off by one, but this
did not solve the issue, so I put it back.

Thanks

Reply via email to