Error for structure definition in Visual C++ - c++

I am facing problem in structure definition which worked fine using gcc
now I want to compile same program in visual studio but some of the conventions are not matching. I have done some changes to the code but I can't figure it out where I am going wrong.
below code is from brg_types.h
#ifndef _BRG_TYPES_H
#define _BRG_TYPES_H
#if defined(__cplusplus)
extern "C" {
#endif
#include <limits.h>
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
# include <stddef.h>
# define ptrint_t intptr_t
#elif defined( __GNUC__ ) && ( __GNUC__ >= 3 )
# include <stdint.h>
# define ptrint_t intptr_t
#else
# define ptrint_t int
#endif
#ifndef BRG_UI8
# define BRG_UI8
# if UCHAR_MAX == 255u
typedef unsigned char uint_8t;
# else
# error Please define uint_8t as an 8-bit unsigned integer type in brg_types.h
# endif
#endif
#ifndef BRG_UI16
# define BRG_UI16
# if USHRT_MAX == 65535u
typedef unsigned short uint_16t;
# else
# error Please define uint_16t as a 16-bit unsigned short type in brg_types.h
# endif
#endif
#ifndef BRG_UI32
# define BRG_UI32
# if UINT_MAX == 4294967295u
# define li_32(h) 0x##h##u
typedef unsigned int uint_32t;
# elif ULONG_MAX == 4294967295u
# define li_32(h) 0x##h##ul
typedef unsigned long uint_32t;
# elif defined( _CRAY )
# error This code needs 32-bit data types, which Cray machines do not provide
# else
# error Please define uint_32t as a 32-bit unsigned integer type in brg_types.h
# endif
#endif
#ifndef BRG_UI64
# if defined( __BORLANDC__ ) && !defined( __MSDOS__ )
# define BRG_UI64
# define li_64(h) 0x##h##ui64
typedef unsigned __int64 uint_64t;
# elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */
# define BRG_UI64
# define li_64(h) 0x##h##ui64
typedef unsigned __int64 uint_64t;
# elif defined( __sun ) && defined( ULONG_MAX ) && ULONG_MAX == 0xfffffffful
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned long long uint_64t;
# elif defined( __MVS__ )
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned int long long uint_64t;
# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u
# if UINT_MAX == 18446744073709551615u
# define BRG_UI64
# define li_64(h) 0x##h##u
typedef unsigned int uint_64t;
# endif
# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u
# if ULONG_MAX == 18446744073709551615ul
# define BRG_UI64
# define li_64(h) 0x##h##ul
typedef unsigned long uint_64t;
# endif
# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u
# if ULLONG_MAX == 18446744073709551615ull
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned long long uint_64t;
# endif
# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u
# if ULONG_LONG_MAX == 18446744073709551615ull
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned long long uint_64t;
# endif
# endif
#endif
#if !defined( BRG_UI64 )
# if defined( NEED_UINT_64T )
# error Please define uint_64t as an unsigned 64 bit type in brg_types.h
# endif
#endif
#ifndef RETURN_VALUES
# define RETURN_VALUES
# if defined( DLL_EXPORT )
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
# define VOID_RETURN __declspec( dllexport ) void __stdcall
# define INT_RETURN __declspec( dllexport ) int __stdcall
# elif defined( __GNUC__ )
# define VOID_RETURN __declspec( __dllexport__ ) void
# define INT_RETURN __declspec( __dllexport__ ) int
# else
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
# endif
# elif defined( DLL_IMPORT )
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
# define VOID_RETURN __declspec( dllimport ) void __stdcall
# define INT_RETURN __declspec( dllimport ) int __stdcall
# elif defined( __GNUC__ )
# define VOID_RETURN __declspec( __dllimport__ ) void
# define INT_RETURN __declspec( __dllimport__ ) int
# else
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
# endif
# elif defined( __WATCOMC__ )
# define VOID_RETURN void __cdecl
# define INT_RETURN int __cdecl
# else
# define VOID_RETURN void
# define INT_RETURN int
# endif
#endif
#define ALIGN_OFFSET(x,n) (((ptrint_t)(x)) & ((n) - 1))
#define ALIGN_FLOOR(x,n) ((uint_8t*)(x) - ( ((ptrint_t)(x)) & ((n) - 1)))
#define ALIGN_CEIL(x,n) ((uint_8t*)(x) + (-((ptrint_t)(x)) & ((n) - 1)))
#define UI_TYPE(size) uint_##size##t
#define UNIT_TYPEDEF(x,size) typedef UI_TYPE(size) x
#define BUFR_TYPEDEF(x,size,bsize) typedef UI_TYPE(size) x[bsize / (size >> 3)]
#define UNIT_CAST(x,size) ((UI_TYPE(size) )(x))
#define UPTR_CAST(x,size) ((UI_TYPE(size)*)(x))
#define u8 uint_8t
#define u32 uint_32t
#define u64 uint_64t
#if defined(__cplusplus)
}
#endif
#endif
Below code is within tables.h
#ifndef __tables_h
#define __tables_h
#include "brg_endian.h"
#define NEED_UINT_64T
//#include "brg_types.h"
#if (PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN)
const u32 T[8*256] __attribute__((aligned(64))) {
/*some code*/
};
#endif /* IS_BIG_ENDIAN */
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
const u32 T[8*256] __attribute__((aligned(64))) = {
/*some code*/
};
#endif /* IS_LITTLE_ENDIAN */
#endif /* __tables_h */
Above code got compiled with gcc compiler
in visual studio use of brg_types.h is done as it is
and tables.h was changed following
#pragma once
#ifndef __tables_h
#define __tables_h
#include "brg_endian.h"
#include "brg_types.h"
#if defined(_MSC_VER)
#define ALIGNED_(x) __declspec(align(x))
#else
#if defined(__GNUC__)
#define ALIGNED_(x) __attribute__ ((aligned(x)))
#endif
#endif
#define ALIGNED_TYPE_(t,x) typedef t ALIGNED_(x)
#pragma pack(1)
#define int8_t __int8
#define int16_t __int16
#define int32_t __int32
#define int64_t __int64
#define uint8_t unsigned __int8
#define uint16_t unsigned __int16
#define uint32_t unsigned __int32
#define uint64_t unsigned __int64
#if (PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN)
const uint32_t T[8*256] ALIGNED_(64) = {
/*some code*/
};
#endif /* IS_BIG_ENDIAN */
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
const uint32_t T[8*256] ALIGNED_(64) = {
};
#endif /* IS_LITTLE_ENDIAN */
#endif /* __tables_h */
Error thrown to me by visual studio is
Error 3 error C1903: unable to recover from previous error(s); stopping compilation
Error 1 error C2144: syntax error : 'int' should be preceded by ';'
Error 2 error C2513: 'int' : no variable declared before '='
near: const uint32_t T[8*256] ALIGNED_(64) = {
/*some code*/
};

Your problem is the ALIGNED_ macro. As it is currently defined, it needs to come before the declaration in VS, but after for GCC. The syntax you want to achieve is:
const uint32_t __declspec(align(64)) T[8*256] = // MSVC
const uint32_t T[8*256] __attribute__ ((aligned(64))) = // GCC
I think the solution is to pass the variable declaration to ALIGNED_, so that the usage looks like:
const uint32_t ALIGNED_(T[8*256], 64) = ...
The definition should look something like:
#if defined(_MSC_VER)
# define ALIGNED_(v, x) __declspec(align(x)) v
#elif defined(__GNUC__)
# define ALIGNED_(v, x) v __attribute__ ((aligned(x)))
#else
# error "Don't know how to define ALIGNED_"
#endif
Warning: This code has not been seen by any compiler. Assume it contains errors.
I don't know how to handle the definition of ALIGNED_TYPE because I can't see an example of its use.

Related

count #define or const variables at compile time

In C++, I have some #define and also a count like this:
#define USE_1
#undef USE_2
#define USE_3
const size_t NUM_USE = (
0
#ifdef USE_1
+ 1
#endif
#ifdef USE_2
+ 1
#endif
#ifdef USE_3
+ 1
#endif
);
Now, I want to use it like this, which does not work as const variable cannot be used in a #if preprocessor statement:
#if NUM_USE > 0
// define here some specific code
#endif
One way to solve it would be to make some extra defines like this:
#ifdef USE_1
#define HAVE_ANY_USE
#else
#ifdef USE_2
#define HAVE_ANY_USE
#else
#ifdef USE_3
#define HAVE_ANY_USE
#endif
#endif
#endif
#ifdef HAVE_ANY_USE
// define here some specific code
#endif
Is there a more elegant solution, maybe by using NUM_USE from above?
You can define the USEs to be either 1 or 0 and then the sum can be a simple macro:
#define USE_1 1
#define USE_2 0
#define USE_3 1
#define NUM_USE (USE_1 + USE_2 + USE_3)

Chromium `debugger` equivalent, on `gdb` for Cygwin?

How do people trigger a breakpoint on gdb (for Cygwin, specifically) from the very source code?
Like when a JS script has the debugger word in it and Chromium dev tools trigger stop for debugging?
Here's how SDL2 implements this feature:
#if defined(_MSC_VER)
/* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak()
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif defined(__386__) && defined(__WATCOMC__)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
#include <signal.h>
#define SDL_TriggerBreakpoint() raise(SIGTRAP)
#else
/* How do we trigger breakpoints on this platform? */
#define SDL_TriggerBreakpoint()
#endif
The conditionals should probably resolve to __asm__ __volatile__ ( "int $3\n\t" ) on Cygwin.

Implicit Declaration of Function that Appears to be Definied

I'm porting the Texas Instruments SimpleLink driver to use with an Xmega host, and I'm getting a few implicit declaration errors when trying to build it. I know what the error means, but as far as I can tell, it should be defined. I must be missing something, I'm hoping someone can help me out.
Here is the error output, it's saying the function CC3120Disable is implicitly declared in the device.c file:
Error implicit declaration of function 'CC3120Disable' [-Werror=implicit-function-declaration] Xmega Firmware D:\CC3120SDK_1.55.00.42\simplelink_sdk_wifi_plugin_1_55_00_42\source\ti\drivers\net\wifi\source\device.c 173
device.c is pretty huge, so here are the includes, they are the very first thing in the file aside from comments:
#include <ti/drivers/net/wifi/simplelink.h>
#include <ti/drivers/net/wifi/source/protocol.h>
#include <ti/drivers/net/wifi/source/driver.h>
#include <ti/drivers/net/wifi/source/flowcont.h>
The first one (simplelink.h) starts a trail to where the function is declared, here is the first part of simplelink.h, again excluding the preamble comments:
#ifndef __SIMPLELINK_H__
#define __SIMPLELINK_H__
/* define the default types
* If user wants to overwrite it,
* he need to undef and define again */
#define _u8 unsigned char
#define _i8 signed char
#define _u16 unsigned short
#define _i16 signed short
#define _u32 unsigned long
#define _i32 signed long
#define _volatile volatile
#define _const const
#include <ti/drivers/net/wifi/porting/user.h>
#ifdef __cplusplus
extern "C"
{
#endif
user.h contains the macro definition that tells it to use the function CC3120Disable, and also an include that contains the declaration of that function. Here is the first part of user.h, without the leading comments:
#ifndef __USER_H__
#define __USER_H__
#include "board.h"
#include "noos.h"
#include "SPI.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
and here is line 371 in user.h that defines the macro:
#define sl_DeviceDisable() CC3120Disable()
Finally, here is all of my board.h file, which has the declaration of the function in question:
#ifndef BOARD_H_
#define BOARD_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include <asf.h>
#include "SPI.h"
/* Typedefs */
//typedef void (*P_EVENT_HANDLER)(void* pValue);
/* Pins */
#define nHIB_PIN IOPORT_CREATE_PIN( PORTD, 7 )
#define CC3120_INT_PIN IOPORT_CREATE_PIN( PORTD, 6 )
#define CC3120_RESET_PIN IOPORT_CREATE_PIN( PORTA, 1 )
#define CC3120_SLAVE_PIN IOPORT_CREATE_PIN( PORTE, 0 )
#define LED_BLUE IOPORT_CREATE_PIN( PORTA, 5 )
#define LED_GREEN IOPORT_CREATE_PIN( PORTA, 6 )
/* USART pins */
#define USARTC0_XCK IOPORT_CREATE_PIN( PORTC, 1 )
#define USARTC0_TXD IOPORT_CREATE_PIN( PORTC, 3 )
#define USARTC1_XCK IOPORT_CREATE_PIN( PORTC, 5 )
#define USARTC1_TXD IOPORT_CREATE_PIN( PORTC, 7 )
//#define USARTD0_XCK IOPORT_CREATE_PIN( PORTD, 1 )
//#define USARTD0_TXD IOPORT_CREATE_PIN( PORTD, 3 )
//#define USARTD1_XCK IOPORT_CREATE_PIN( PORTD, 5 )
//#define USARTD1_TXD IOPORT_CREATE_PIN( PORTD, 7 )
#define USARTE0_XCK IOPORT_CREATE_PIN( PORTE, 1 )
#define USARTE0_RXD IOPORT_CREATE_PIN( PORTE, 2 )
#define USARTE0_TXD IOPORT_CREATE_PIN( PORTE, 3 )
//#define USARTE1_XCK IOPORT_CREATE_PIN( PORTE, 5 )
//#define USARTE1_TXD IOPORT_CREATE_PIN( PORTE, 7 )
//#define USARTF0_XCK IOPORT_CREATE_PIN( PORTF, 1 )
//#define USARTF0_TXD IOPORT_CREATE_PIN( PORTF, 3 )
/* Functions */
void CC3120Disable( void );
void CC3120Enable( void );
uint8_t CC3120RegisterInterruptHandler( P_EVENT_HANDLER InterruptHdl , void* pValue );
void CC3120MaskIntHdlr( void );
void CC3120UnMaskIntHdlr( void );
void clock_init( void );
void init( void );
#ifdef __cplusplus
}
#endif
#endif /* BOARD_H_ */
The function is defined in board.cpp, here is the beginning of that file, up to where the function is:
#include <asf.h>
#include "board.h"
#include "socket.h"
/* Variables */
P_EVENT_HANDLER CC3120IrqHandler = 0;
uint8_t intIsMasked = 0;
/* Interrupt Handler */
ISR( PORTD_INT0_vect )
{
if ( CC3120IrqHandler && !intIsMasked )
CC3120IrqHandler( 0 );
}
void CC3120Disable()
{
ioport_set_pin_level( nHIB_PIN, false );
}
It's making me crazy, I can't figure out why it's throwing an implicit declaration error for that function. Can anybody see a problem or suggest something to try?

Microsoft C++ Pre-defined Macros [duplicate]

This question already has answers here:
How to find out cl.exe's built-in macros
(7 answers)
Closed 6 years ago.
Is there a cl.exe option to dump all the pre-defined Macros ( along with the defined values ).
Something like gcc -dM -E - < /dev/null for gcc.
Unfortunately, I don't think MSVC has a built in way of doing this.
I've used the following program to dump values of 'known' predefined symbols. I should give attribution (because I know I didn't come up with this), but I don't have notes on where I got it from (update: looks like I probably got it from here: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/644c12ed-e3a7-4c5a-a73a-610fcc7913ca)...
#define __STR2__(x) #x
#define __STR1__(x) __STR2__(x)
#define __PPOUT__(x) "#define " #x " " __STR1__(x)
#if defined(_ATL_VER)
#pragma message(__PPOUT__(_ATL_VER ))
#endif
#if defined(_CHAR_UNSIGNED )
#pragma message(__PPOUT__(_CHAR_UNSIGNED ))
#endif
#if defined(__CLR_VER )
#pragma message(__PPOUT__(__CLR_VER ))
#endif
#if defined(__cplusplus_cli )
#pragma message(__PPOUT__(__cplusplus_cli ))
#endif
#if defined(__COUNTER__ )
#pragma message(__PPOUT__(__COUNTER__ ))
#endif
#if defined(__cplusplus )
#pragma message(__PPOUT__(__cplusplus ))
#endif
#if defined(_CPPLIB_VER )
#pragma message(__PPOUT__(_CPPLIB_VER ))
#endif
#if defined(_CPPRTTI )
#pragma message(__PPOUT__(_CPPRTTI ))
#endif
#if defined(_CPPUNWIND )
#pragma message(__PPOUT__(_CPPUNWIND ))
#endif
#if defined(_DEBUG )
#pragma message(__PPOUT__(_DEBUG ))
#endif
#if defined(_DLL )
#pragma message(__PPOUT__(_DLL ))
#endif
#if defined(__FUNCDNAME__ )
#pragma message(__PPOUT__(__FUNCDNAME__ ))
#endif
#if defined(__FUNCSIG__ )
#pragma message(__PPOUT__(__FUNCSIG__ ))
#endif
#if defined(__FUNCTION__ )
#pragma message(__PPOUT__(__FUNCTION__ ))
#endif
#if defined(_INTEGRAL_MAX_BITS )
#pragma message(__PPOUT__(_INTEGRAL_MAX_BITS ))
#endif
#if defined(_M_ALPHA )
#pragma message(__PPOUT__(_M_ALPHA ))
#endif
#if defined(_M_CEE )
#pragma message(__PPOUT__(_M_CEE ))
#endif
#if defined(_M_CEE_PURE )
#pragma message(__PPOUT__(_M_CEE_PURE ))
#endif
#if defined(_M_CEE_SAFE )
#pragma message(__PPOUT__(_M_CEE_SAFE ))
#endif
#if defined(_M_IX86 )
#pragma message(__PPOUT__(_M_IX86 ))
#endif
#if defined(_M_IA64 )
#pragma message(__PPOUT__(_M_IA64 ))
#endif
#if defined(_M_IX86_FP )
#pragma message(__PPOUT__(_M_IX86_FP ))
#endif
#if defined(_M_MPPC )
#pragma message(__PPOUT__(_M_MPPC ))
#endif
#if defined(_M_MRX000 )
#pragma message(__PPOUT__(_M_MRX000 ))
#endif
#if defined(_M_PPC )
#pragma message(__PPOUT__(_M_PPC ))
#endif
#if defined(_M_X64 )
#pragma message(__PPOUT__(_M_X64 ))
#endif
#if defined(_MANAGED )
#pragma message(__PPOUT__(_MANAGED ))
#endif
#if defined(_MFC_VER )
#pragma message(__PPOUT__(_MFC_VER ))
#endif
#if defined(_MSC_BUILD )
#pragma message(__PPOUT__(_MSC_BUILD ))
#endif
#if defined(_MSC_EXTENSIONS )
#pragma message(__PPOUT__(_MSC_EXTENSIONS ))
#endif
#if defined(_MSC_FULL_VER )
#pragma message(__PPOUT__(_MSC_FULL_VER ))
#endif
#if defined(_MSC_VER )
#pragma message(__PPOUT__(_MSC_VER ))
#endif
#if defined(__MSVC_RUNTIME_CHECKS )
#pragma message(__PPOUT__(__MSVC_RUNTIME_CHECKS ))
#endif
#if defined(_MT )
#pragma message(__PPOUT__(_MT ))
#endif
#if defined(_NATIVE_WCHAR_T_DEFINED)
#pragma message(__PPOUT__(_NATIVE_WCHAR_T_DEFINED))
#endif
#if defined(_OPENMP )
#pragma message(__PPOUT__(_OPENMP ))
#endif
#if defined(_VC_NODEFAULTLIB )
#pragma message(__PPOUT__(_VC_NODEFAULTLIB ))
#endif
#if defined(_WCHAR_T_DEFINED )
#pragma message(__PPOUT__(_WCHAR_T_DEFINED ))
#endif
#if defined(_WIN32 )
#pragma message(__PPOUT__(_WIN32 ))
#endif
#if defined(_WIN64 )
#pragma message(__PPOUT__(_WIN64 ))
#endif
#if defined(_Wp64 )
#pragma message(__PPOUT__(_Wp64 ))
#endif
void main() {}
I don't see that option in the MSDN documentation, but the list of predefined macros for Visual Studio 2008 and 2010 are available.

why imaxdiv_t __cdecl in such function does not want to compile under /clr:pure?

so I have such code in my VS ffmpeg video encoder project in C++ which compies perfectly under CLR (inttypes.h part of ffmpeg's includes)
// ISO C9x compliant inttypes.h for Miscrosoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_INTTYPES_H_ // [
#define _MSC_INTTYPES_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <stdint.h>
// 7.8 Format conversion of integer types
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
// 7.8.1 Macros for format specifiers
// The fprintf macros for signed integers are:
#define PRId8 "d"
#define PRIi8 "i"
#define PRIdLEAST8 "d"
#define PRIiLEAST8 "i"
#define PRIdFAST8 "d"
#define PRIiFAST8 "i"
#define PRId16 "hd"
#define PRIi16 "hi"
#define PRIdLEAST16 "hd"
#define PRIiLEAST16 "hi"
#define PRIdFAST16 "hd"
#define PRIiFAST16 "hi"
#define PRId32 "I32d"
#define PRIi32 "I32i"
#define PRIdLEAST32 "I32d"
#define PRIiLEAST32 "I32i"
#define PRIdFAST32 "I32d"
#define PRIiFAST32 "I32i"
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIdLEAST64 "I64d"
#define PRIiLEAST64 "I64i"
#define PRIdFAST64 "I64d"
#define PRIiFAST64 "I64i"
#define PRIdMAX "I64d"
#define PRIiMAX "I64i"
#define PRIdPTR "Id"
#define PRIiPTR "Ii"
// The fprintf macros for unsigned integers are:
#define PRIo8 "o"
#define PRIu8 "u"
#define PRIx8 "x"
#define PRIX8 "X"
#define PRIoLEAST8 "o"
#define PRIuLEAST8 "u"
#define PRIxLEAST8 "x"
#define PRIXLEAST8 "X"
#define PRIoFAST8 "o"
#define PRIuFAST8 "u"
#define PRIxFAST8 "x"
#define PRIXFAST8 "X"
#define PRIo16 "ho"
#define PRIu16 "hu"
#define PRIx16 "hx"
#define PRIX16 "hX"
#define PRIoLEAST16 "ho"
#define PRIuLEAST16 "hu"
#define PRIxLEAST16 "hx"
#define PRIXLEAST16 "hX"
#define PRIoFAST16 "ho"
#define PRIuFAST16 "hu"
#define PRIxFAST16 "hx"
#define PRIXFAST16 "hX"
#define PRIo32 "I32o"
#define PRIu32 "I32u"
#define PRIx32 "I32x"
#define PRIX32 "I32X"
#define PRIoLEAST32 "I32o"
#define PRIuLEAST32 "I32u"
#define PRIxLEAST32 "I32x"
#define PRIXLEAST32 "I32X"
#define PRIoFAST32 "I32o"
#define PRIuFAST32 "I32u"
#define PRIxFAST32 "I32x"
#define PRIXFAST32 "I32X"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#define PRIoLEAST64 "I64o"
#define PRIuLEAST64 "I64u"
#define PRIxLEAST64 "I64x"
#define PRIXLEAST64 "I64X"
#define PRIoFAST64 "I64o"
#define PRIuFAST64 "I64u"
#define PRIxFAST64 "I64x"
#define PRIXFAST64 "I64X"
#define PRIoMAX "I64o"
#define PRIuMAX "I64u"
#define PRIxMAX "I64x"
#define PRIXMAX "I64X"
#define PRIoPTR "Io"
#define PRIuPTR "Iu"
#define PRIxPTR "Ix"
#define PRIXPTR "IX"
// The fscanf macros for signed integers are:
#define SCNd8 "d"
#define SCNi8 "i"
#define SCNdLEAST8 "d"
#define SCNiLEAST8 "i"
#define SCNdFAST8 "d"
#define SCNiFAST8 "i"
#define SCNd16 "hd"
#define SCNi16 "hi"
#define SCNdLEAST16 "hd"
#define SCNiLEAST16 "hi"
#define SCNdFAST16 "hd"
#define SCNiFAST16 "hi"
#define SCNd32 "ld"
#define SCNi32 "li"
#define SCNdLEAST32 "ld"
#define SCNiLEAST32 "li"
#define SCNdFAST32 "ld"
#define SCNiFAST32 "li"
#define SCNd64 "I64d"
#define SCNi64 "I64i"
#define SCNdLEAST64 "I64d"
#define SCNiLEAST64 "I64i"
#define SCNdFAST64 "I64d"
#define SCNiFAST64 "I64i"
#define SCNdMAX "I64d"
#define SCNiMAX "I64i"
#ifdef _WIN64 // [
# define SCNdPTR "I64d"
# define SCNiPTR "I64i"
#else // _WIN64 ][
# define SCNdPTR "ld"
# define SCNiPTR "li"
#endif // _WIN64 ]
// The fscanf macros for unsigned integers are:
#define SCNo8 "o"
#define SCNu8 "u"
#define SCNx8 "x"
#define SCNX8 "X"
#define SCNoLEAST8 "o"
#define SCNuLEAST8 "u"
#define SCNxLEAST8 "x"
#define SCNXLEAST8 "X"
#define SCNoFAST8 "o"
#define SCNuFAST8 "u"
#define SCNxFAST8 "x"
#define SCNXFAST8 "X"
#define SCNo16 "ho"
#define SCNu16 "hu"
#define SCNx16 "hx"
#define SCNX16 "hX"
#define SCNoLEAST16 "ho"
#define SCNuLEAST16 "hu"
#define SCNxLEAST16 "hx"
#define SCNXLEAST16 "hX"
#define SCNoFAST16 "ho"
#define SCNuFAST16 "hu"
#define SCNxFAST16 "hx"
#define SCNXFAST16 "hX"
#define SCNo32 "lo"
#define SCNu32 "lu"
#define SCNx32 "lx"
#define SCNX32 "lX"
#define SCNoLEAST32 "lo"
#define SCNuLEAST32 "lu"
#define SCNxLEAST32 "lx"
#define SCNXLEAST32 "lX"
#define SCNoFAST32 "lo"
#define SCNuFAST32 "lu"
#define SCNxFAST32 "lx"
#define SCNXFAST32 "lX"
#define SCNo64 "I64o"
#define SCNu64 "I64u"
#define SCNx64 "I64x"
#define SCNX64 "I64X"
#define SCNoLEAST64 "I64o"
#define SCNuLEAST64 "I64u"
#define SCNxLEAST64 "I64x"
#define SCNXLEAST64 "I64X"
#define SCNoFAST64 "I64o"
#define SCNuFAST64 "I64u"
#define SCNxFAST64 "I64x"
#define SCNXFAST64 "I64X"
#define SCNoMAX "I64o"
#define SCNuMAX "I64u"
#define SCNxMAX "I64x"
#define SCNXMAX "I64X"
#ifdef _WIN64 // [
# define SCNoPTR "I64o"
# define SCNuPTR "I64u"
# define SCNxPTR "I64x"
# define SCNXPTR "I64X"
#else // _WIN64 ][
# define SCNoPTR "lo"
# define SCNuPTR "lu"
# define SCNxPTR "lx"
# define SCNXPTR "lX"
#endif // _WIN64 ]
// 7.8.2 Functions for greatest-width integer types
// 7.8.2.1 The imaxabs function
#define imaxabs _abs64
// 7.8.2.2 The imaxdiv function
// This is modified version of div() function from Microsoft's div.c found
// in %MSVC.NET%\crt\src\div.c
#ifdef STATIC_IMAXDIV // [
static
#else // STATIC_IMAXDIV ][
_inline
#endif // STATIC_IMAXDIV ]
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
{
imaxdiv_t result;
result.quot = numer / denom;
result.rem = numer % denom;
if (numer < 0 && result.rem > 0) {
// did division wrong; must fix up
++result.quot;
result.rem -= denom;
}
return result;
}
// 7.8.2.3 The strtoimax and strtoumax functions
#define strtoimax _strtoi64
#define strtoumax _strtoui64
// 7.8.2.4 The wcstoimax and wcstoumax functions
#define wcstoimax _wcstoi64
#define wcstoumax _wcstoui64
#endif // _MSC_INTTYPES_H_ ]
But When I try /clr:pure option it just gives me 2 errors C3641 all in this code. Is there any way how to compile my project under CLR:PURE? Please help.
It seems you should use __clrcall instead of __cdecl. from: Compiler Error C3641