Skip to content

Commit 1534077

Browse files
committed
Merge pull request #264 from rtucker/win-mingw-fixes-inttypes
Support Windows builds with MinGW
2 parents d685097 + c9f3945 commit 1534077

File tree

9 files changed

+31
-21
lines changed

9 files changed

+31
-21
lines changed

debian/copyright

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ License: BSD-2-clause
122122
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
123123
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
124124

125-
Files: host/common/include/windows/inttypes.h
125+
Files: host/common/include/windows/inttypes_msvc.h
126126
Copyright: 2006-2013 Alexander Chemeris
127127
Comment: Not used in building Debian packages
128128
License: BSD-3-clause

host/common/include/host_config.h.in

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,28 @@
152152
#elif BLADERF_OS_WINDOWS
153153

154154
/* Rename a few functions and types */
155-
#include <Windows.h>
156-
#define strtok_r strtok_s
157-
#define strtoull _strtoui64
158-
#define snprintf _snprintf
159-
#define vsnprintf _vsnprintf
160-
#define strcasecmp _stricmp
161-
#define strncasecmp _strnicmp
162-
#define fileno _fileno
163-
#define strdup _strdup
155+
#include <windows.h>
164156
#define usleep(x) Sleep((x+999)/1000)
165157

158+
/* Changes specific to Microsoft Visual Studio and its C89-compliant ways */
159+
#if _MSC_VER
160+
# define strtok_r strtok_s
161+
# define strtoull _strtoui64
162+
# define snprintf _snprintf
163+
# define vsnprintf _vsnprintf
164+
# define strcasecmp _stricmp
165+
# define strncasecmp _strnicmp
166+
# define fileno _fileno
167+
# define strdup _strdup
168+
166169
/* ssize_t lives elsewhere */
167-
#include <BaseTsd.h>
168-
#define ssize_t SSIZE_T
170+
# include <BaseTsd.h>
171+
# define ssize_t SSIZE_T
169172

170173
/* With msvc, inline is only available for C++. Otherwise we need to use __inline:
171174
* http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx */
172-
#define inline __inline
175+
# define inline __inline
176+
#endif // _MSC_VER
173177

174178
#endif
175179

@@ -184,10 +188,17 @@
184188
* Here's a sample regexep you could use in vim to clean these up in your code:
185189
* @\(\s\+\)\(\.[a-zA-Z0-9_]\+\)\s*=\s*\([a-zA-Z0-9_]\+\)\(,\)\?@\1FIELD_INIT(\2,\3)\4@gc
186190
*/
187-
#if BLADERF_OS_WINDOWS
191+
#if _MSC_VER
188192
# define FIELD_INIT(field, ...) __VA_ARGS__
189193
#else
190194
# define FIELD_INIT(field, ...) field = __VA_ARGS__
191-
#endif
195+
#endif // _MSC_VER
196+
197+
/* MSVC doesn't have inttypes.h. We'll use a local version for this environment. */
198+
#if _MSC_VER
199+
# include <inttypes_msvc.h>
200+
#else
201+
# include <inttypes.h>
202+
#endif // _MSC_VER
192203

193204
#endif

host/libraries/libbladeRF/src/file_ops.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <sys/types.h>
2626
#include <string.h>
2727
#include <errno.h>
28-
#include <inttypes.h>
2928
#include <libbladeRF.h>
3029
#include "host_config.h"
3130
#include "file_ops.h"

host/libraries/libbladeRF/src/si5338.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*/
2121
#include <string.h>
22-
#include <inttypes.h>
2322
#include "rel_assert.h"
2423

2524
#include "libbladeRF.h"
25+
#include "host_config.h"
2626
#include "bladerf_priv.h"
2727
#include "log.h"
2828

host/utilities/bladeRF-cli/src/cmd/flash_image.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
#include <stdio.h>
2424
#include <limits.h>
2525
#include <time.h>
26-
#include <inttypes.h>
26+
2727
#include <libbladeRF.h>
2828

29+
#include "host_config.h"
2930
#include "cmd.h"
3031
#include "common.h"
3132
#include "conversions.h"

host/utilities/bladeRF-cli/src/cmd/printset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <limits.h>
2121
#include <stdint.h>
2222
#include <string.h>
23-
#include <inttypes.h>
23+
#include "host_config.h"
2424
#include "cmd.h"
2525
#include "conversions.h"
2626

host/utilities/bladeRF-cli/src/cmd/rx.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <limits.h>
2626
#include <errno.h>
2727
#include <string.h>
28-
#include <inttypes.h>
2928

3029
#include "rel_assert.h"
3130
#include "host_config.h"

host/utilities/bladeRF-cli/src/cmd/rxtx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#include <limits.h>
2222
#include <pthread.h>
2323
#include <errno.h>
24-
#include <inttypes.h>
2524

2625
#include "host_config.h"
26+
2727
#if BLADERF_OS_WINDOWS || BLADERF_OS_OSX
2828
#include "clock_gettime.h"
2929
#else

0 commit comments

Comments
 (0)