portability

How portable is mktemp(1)?

不想你离开。 提交于 2019-12-17 22:23:01
问题 As the title suggests — can I be reasonably sure that mktemp will exist on any unix-y operating system I'm likely to encounter? 回答1: POSIX does not seem to specify mktemp(1) . It looks like most modern systems have it, but the available functionality and the semantics of the options vary between implementations (so particular invocations may not be portable): mktemp(1) from OpenBSD — mktemp(1) originated in OpenBSD 2.1 mktemp(1) from FreeBSD mktemp(1) from Mac OS X — almost always the same as

How do I type a floating point infinity literal in python

与世无争的帅哥 提交于 2019-12-17 18:00:25
问题 How do I type a floating point infinity literal in python? I have heard inf = float('inf') is non portable. Thus, I have had the following recommended: inf = 1e400 Is either of these standard, or portable? What is best practice? 回答1: In python 2.6 it is portable if the CPU supports it The float() function will now turn the string nan into an IEEE 754 Not A Number value, and +inf and -inf into positive or negative infinity. This works on any platform with IEEE 754 semantics. 回答2: float('inf')

How to install external libraries with Portable Python?

二次信任 提交于 2019-12-17 16:49:26
问题 I can't install Python on my machine due to administrator privileges, but I did download/open Portable Python successfully. I am on a Windows 7 64-bit machine. How would I be able to use the external libraries from before, such as Numpy or Gmpy? 回答1: easy_install is trying to install from source. gmpy and gmpy2 are C extensions and require the presence of a compatible C compiler and other libraries (GMP; and MPFR and MPC for gmpy2). Installing from source is frequently difficult on Windows.

portable way to deal with 64/32 bit time_t

两盒软妹~` 提交于 2019-12-17 16:32:54
问题 I have some code which is built both on Windows and Linux. Linux at this point is always 32bit but Windows is 32 and 64bit. Windows wants to have time_t be 64 bit and Linux still has it as 32 bit. I'm fine with that, except in some places time_t values are converted to strings. So when time_T is 32 bit it should be done with %d and when it is 64bit with %lld... what is the smart way to do this? Also: any ideas how I may find all places where time_t's are passed to printf-style functions to

What is the smallest possible Windows (PE) executable?

耗尽温柔 提交于 2019-12-17 06:30:31
问题 As a precursor to writing a compiler I'm trying to understand the Windows (32-bit) Portable Executable format. In particular I'd like to see an example of a bare-bones executable which does nothing except load correctly, run and exit. I've tried writing and compiling a simple C main function which does nothing but the resulting .exe is ~22KB and contains many imports from KERNEL32.DLL (presumably used by LIBC to set up environment, heaps etc.). Even the DOS Header could probably be smaller

Converting Little Endian to Big Endian

旧巷老猫 提交于 2019-12-17 05:04:37
问题 All, I have been practicing coding problems online. Currently I am working on a problem statement Problems where we need to convert Big Endian <-> little endian. But I am not able to jot down the steps considering the example given as: 123456789 converts to 365779719 The logic I am considering is : 1 > Get the integer value (Since I am on Windows x86, the input is Little endian) 2 > Generate the hex representation of the same. 3 > Reverse the representation and generate the big endian integer

Is there any “standard” htonl-like function for 64 bits integers in C++?

柔情痞子 提交于 2019-12-17 04:23:14
问题 I'm working on an implementation of the memcache protocol which, at some points, uses 64 bits integer values. These values must be stored in "network byte order". I wish there was some uint64_t htonll(uint64_t value) function to do the change, but unfortunately, if it exist, I couldn't find it. So I have 1 or 2 questions: Is there any portable (Windows, Linux, AIX) standard function to do this ? If there is no such function, how would you implement it ? I have in mind a basic implementation

Is there any “standard” htonl-like function for 64 bits integers in C++?

泄露秘密 提交于 2019-12-17 04:22:06
问题 I'm working on an implementation of the memcache protocol which, at some points, uses 64 bits integer values. These values must be stored in "network byte order". I wish there was some uint64_t htonll(uint64_t value) function to do the change, but unfortunately, if it exist, I couldn't find it. So I have 1 or 2 questions: Is there any portable (Windows, Linux, AIX) standard function to do this ? If there is no such function, how would you implement it ? I have in mind a basic implementation

\n and \r seem to work everywhere. Why is line.separator more portable?

情到浓时终转凉″ 提交于 2019-12-14 00:47:56
问题 I was just perusing through questions, and I found System.getProperty(line.separator) used in place of \n with the author's comment that the code was "portable". Reading through various forums, I've seen two groups: People who say there's a difference between Linux's and Windows' interpretation of newline characters, and this compensates for that (with no clear evidence). People who say there's no difference by showing code and output examples, which obviously only applies to that code

Boost Python portability concerns

青春壹個敷衍的年華 提交于 2019-12-13 13:28:58
问题 I have a dll written in C++ that I want to export to Python for running regression and unit-testing (it's just easier to maintain and run the regression with Python). To this purpose I want to use Boost.Python to export the main API of the dll so it will be usable in Python. My assemblies look as follows: MyLibrary.dll //main API C++ library MyLibrary.pyd //a thin dll project containing only the BOOST_PYTHON_MODULE export definitions (dependant on MyLibrary.dll) ... //other C++ dll files that