diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-14 10:09:26 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-14 10:09:26 -0800 |
commit | 7d64b9f4794013b3a20fb1d79b3805e3bd4f3b35 (patch) | |
tree | 69de0f9220e6dceb19f025c3de7bca2707c24d01 /host/include | |
parent | 4818bd27f07acea1e663086d59fbb7d44bd5af81 (diff) | |
download | uhd-7d64b9f4794013b3a20fb1d79b3805e3bd4f3b35.tar.gz uhd-7d64b9f4794013b3a20fb1d79b3805e3bd4f3b35.tar.bz2 uhd-7d64b9f4794013b3a20fb1d79b3805e3bd4f3b35.zip |
uhd: make static block safe with a try,catch,print
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/utils/static.hpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/host/include/uhd/utils/static.hpp b/host/include/uhd/utils/static.hpp index c61f10884..82cdf36d9 100644 --- a/host/include/uhd/utils/static.hpp +++ b/host/include/uhd/utils/static.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -30,8 +30,17 @@ /*! * Defines a static code block that will be called before main() - * \param _x the name of the defined struct (must be unique in file) + * The static block will catch and print exceptions to std error. + * \param _x the unique name of the fixture (unique per source) */ -#define UHD_STATIC_BLOCK(_x) static struct _x{_x();}_x;_x::_x() +#define UHD_STATIC_BLOCK(_x) \ + void _x(void); \ + static _uhd_static_fixture _x##_fixture(&_x, #_x); \ + void _x(void) + +//! Helper for static block, constructor calls function +struct UHD_API _uhd_static_fixture{ + _uhd_static_fixture(void (*)(void), const char *); +}; #endif /* INCLUDED_UHD_UTILS_STATIC_HPP */ |