Upgrading from Agent++ v3.4.5 to v3.5

janzen janzen____pixelmetrix.com
Thu Sep 6 10:17:17 CEST 2001


Hi, Frank!  I'm in the process of upgrading from Agent++ v3.4.5 to v3.5,
and from SNMP++ v3.1.1 to v3.1.3b.  I've run into a few small issues
for which I thought I'd send in some workarounds:


1) Currently my agent code is all single-threaded.  There's a comment
in agent++/include/agent++.h and snmp++/include/config.h headers which
says, "uncomment this if you do not want pthreads" -- but the next
line doesn't seem to match the comment.  It would be nice if it were
similar to what you've provided for the _NO_LOGGING option, which can
be set either from the Makefile or by changing the header.  (See below.)


2) Also, the #ifdefs for thread support on non-Windows systems have
changed in Agent++ 3.5's agent++.h, but not in SNMP++ 3.1.3b's config.h.
These should be the same, right?


3) If so, then we can do this only in the SNMP++ config.h file, and can
remove it from agent++.h just as you've done with _SNMPv3.  (BTW, that
one could be controlled by a _NO_SNMPv3 option too, for consistency.)


4) There should be an '#ifdef _THREADS' around the '#define
AGENTPP_USE_THREAD_POOL' line.


5) The addition of 'namespace' is great; thanks very much for that!!
Re. the surrounding '#ifdef __GNU__', though, I found that g++'s
preprocessor doesn't define a __GNU__ symbol on my system, but does
define the following (as well as a bunch of other, architecture-
specific ones):

$ touch x.c; g++ -E -Wp,-dM x.c
#define __linux__ 1
#define __EXCEPTIONS 1
#define linux 1
#define __cplusplus 1
#define __GNUC_MINOR__ 95
#define __unix 1
#define __unix__ 1
#define __GNUC__ 2
#define __GNUG__ 2
#define __linux 1
#define unix 1             
...

The reason for the difference is that the __GNU__ symbol actually
refers to the *operating system* rather than the compiler, which is
why mine has __linux__ instead.  Using __GNU__ actually involves
you into a whole political war; namely, the 'GNU/Hurd' vs. 'GNU/Linux'
vs. 'Linux' vs. '...' morass.  I don't think we want to go there!

Instead, the critical information here is whether the compiler has
reasonable support for namespaces.  For g++ this would look
something like the following:

#ifdef __GNUC__
#if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 91))
#define AGENTPP_NAMESPACE
#endif
#endif

[Bracing myself for flames about def'n. of 'reasonable' wrt. various
g++ versions...]


6) Once the AGENTPP_NAMESPACE is defined properly, I found that in
mib.cpp and threads.cpp the nesting of #ifdefs isn't quite right.
In both cases, the

  #ifdef AGENTPP_NAMESPACE
  }
  #endif

lines should be the very last in the file, coming *after* the #endif
which corresponds to the '#ifdef _THREADS'.  (Comments after #endif
statements would help to prevent or at least find these!)


7) Is there any interest in namespaces for SNMP++?  I'd be happy to
add these, but only if I were certain that this would become part of
the distribution.  (My earlier patches re. const correctness appear
not to have been of interest to anyone else, perhaps due to backward
compatibility issues...?)


I've attached my modified agent++.h and config.h files, which should
be fairly self-explanatory.  I hope you'll find these changes useful,
and will adopt them (or something similar) in the standard distribution.

Thanks...

--
Martin Janzen
janzen at pixelmetrix.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: agent++.h
Type: application/octet-stream
Size: 6700 bytes
Desc: not available
Url : http://lists.agentpp.org/pipermail/agentpp/attachments/20010906/6855dd40/attachment.dll 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.h
Type: application/octet-stream
Size: 2013 bytes
Desc: not available
Url : http://lists.agentpp.org/pipermail/agentpp/attachments/20010906/6855dd40/attachment-0001.dll 


More information about the AGENTPP mailing list