Jump to content

  • Log In with Google      Sign In   
  • Create Account


Errors in Unix to Windows conversion


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Jarwulf   Members   -  Reputation: 222

Like
-1Likes
Like

Posted 29 April 2012 - 03:59 PM

I'm trying to port an algoreithm from a unix program to something that will compile in visual studio. I've had to find and include a unistd.h a getopt.c and a stdint.h I found online. I'm still getting some errors that might be because of differences between systems.

1st error
Error 4 error C2371: 'int8_t' : redefinition; different basic types c:\users\minion\documents\visual studio 2008\library\bam2bed\stdint.h 82 BAM2BED



#include <limits.h>

// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
//   error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#ifdef __cplusplus
extern "C" {
#endif
#  include <wchar.h>
#ifdef __cplusplus
}
#endif

// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
#	 define _W64 __w64
#  else
#	 define _W64
#  endif
#endif


// 7.18.1 Integer types

// 7.18.1.1 Exact-width integer types

// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
   typedef signed char	   int8_t;
   typedef signed short	  int16_t;
   typedef signed int		int32_t;
   typedef unsigned char	 uint8_t;
   typedef unsigned short	uint16_t;
   typedef unsigned int	  uint32_t;
#else
   typedef signed __int8	 int8_t; //ERROR IS HERE
   typedef signed __int16	int16_t;
   typedef signed __int32	int32_t;
   typedef unsigned __int8   uint8_t;
   typedef unsigned __int16  uint16_t;
   typedef unsigned __int32  uint32_t;
#endif
typedef signed __int64	   int64_t;
typedef unsigned __int64	 uint64_t;


second error
Error 5 error C2039: 'isdigit' : is not a member of 'std' c:\users\minion\documents\visual studio 2008\library\bam2bed\bedfile.h 336 BAM2BED

// return the genome "bin" for a feature with this start and end
inline
BIN getBin(CHRPOS start, CHRPOS end) {
	--end;
	start >>= _binFirstShift;
	end   >>= _binFirstShift;

	for (register short i = 0; i < _binLevels; ++i) {
		if (start == end) return _binOffsetsExtended[i] + start;
		start >>= _binNextShift;
		end   >>= _binNextShift;
	}
	cerr << "start " << start << ", end " << end << " out of range in findBin (max is 512M)" << endl;
	return 0;
}

/****************************************************
// isInteger(s): Tests if string s is a valid integer
*****************************************************/
inline bool isInteger(const std::string& s) {
	int len = s.length();
	for (int i = 0; i < len; i++) {
		if (!std::isdigit(s[i])) return false; //ERROR IS HERE
	}
	return true;
}


// return the amount of overlap between two features.  Negative if none and the
// number of negative bases is the distance between the two.
inline
int overlaps(CHRPOS aS, CHRPOS aE, CHRPOS bS, CHRPOS bE) {
	return min(aE, bE) - max(aS, bS);
}

// is A after (to the right of) B?
inline
bool after(const BED &a, const BED &b) {
	return (a.start >= b.end);
}

what might the fix be?

Edited by jbadams, 29 April 2012 - 07:24 PM.
Changed topic title to be less inflammatory; you're welcome to your opinions, but your topic title when asking for help is not an appropriate place for "MS bashing".


Sponsor:

#2 Oolala   Members   -  Reputation: 751

Like
0Likes
Like

Posted 29 April 2012 - 04:42 PM

Likely the problem with error 1 is resultant from a different error elsewhere. The error message is pretty description, you're defining int8_t twice, probably with different types.

The second error is probably due to not including <cctype>. See http://www.cplusplus.com/reference/clibrary/cctype/isdigit/

#3 Jarwulf   Members   -  Reputation: 222

Like
0Likes
Like

Posted 29 April 2012 - 06:54 PM

Likely the problem with error 1 is resultant from a different error elsewhere. The error message is pretty description, you're defining int8_t twice, probably with different types.

The second error is probably due to not including <cctype>. See http://www.cplusplus...cctype/isdigit/


I do see int8_t being defined twice once as a signed char and another as a signed int8 below. Is this the acutal mistake or is it allowable and there must be something else wrong? But as I got this code somewhere else I assumed that it was correct for unix

#if (_MSC_VER < 1300)
   typedef signed char	 int8_t;
   typedef signed short   int16_t;
   typedef signed int		   int32_t;
   typedef unsigned char		 uint8_t;
   typedef unsigned short	   uint16_t;
   typedef unsigned int   uint32_t;
#else
   typedef signed __int8		 int8_t; //ERROR IS HERE


#4 Oolala   Members   -  Reputation: 751

Like
0Likes
Like

Posted 29 April 2012 - 07:17 PM

Due to the ifdef there, the line right below the _MSC_VER check and the line right below the #else are not going to both be compiled. One or the other will be.

You likely have another, seemingly unrelated definition of int8_t some additional place. VS is pretty good about finding these things, if you just ask it to find the definition of it.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS