portability

Android wifi hotspot client connection events

天大地大妈咪最大 提交于 2019-12-03 18:05:48
问题 I am connecting different devices with wifi hotspot AP programatically in my android app, How can i detect the clients being connected and disconnected and to the wifi hotspot AP i turned on programmatically ? Is there any callback event in Android API to give information regarding the connection or disconnection events of individual devices ? Thanks in advance. 回答1: I think you need to use WifiP2pDevice There you can check for available devices, and also if they are connected or not. Try

What's the most cross-platform friendly coding language? [closed]

眉间皱痕 提交于 2019-12-03 17:01:01
Let's say I want to create FPS game, let's say clone Crysis so everybody understand what type of graphics & performance I'm after. What's the best code to write this game with so it's as easy as possible to port it to all the common platforms? Of course I want the application to feel and be native to the platform. This also means that it should be easy to take advantage of Snow Leopard's new features like OpenCL and Windows 7's new features. I realize that GUI has the written separately for different platforms and that's not a problem. So my question is that what's the best language for the

Creating a Portable Python (local install) for Linux

爷,独闯天下 提交于 2019-12-03 16:46:23
问题 I'm looking to create the following: A portable version of python that can be run on any system (with any previous version of python or no python installed) and have it pre-configured with various python packages (ie, django, lxml, pysqlite, etc) The closest I've found to the above is virtualenv, but this only goes so far. If I package up a nice virtualenv for python on one machine, it contains sym links to a lot of the libraries it needs. I can take those sym links and convert them to their

In C how to write whichever end of line character is appropriate to the OS?

梦想与她 提交于 2019-12-03 13:55:27
Unix has \n, Mac was \r but is now \n and DOS/Win32 is \r\n. When creating a text file with C, how to ensure whichever end of line character(s) is appropriate to the OS gets used? fprintf(your_file, "\n"); This will be converted to an appropriate EOL by the stdio library on your operating system provided that you opened the file in text mode. In binary mode no conversion takes place. From Wikipedia: When writing a file in text mode, '\n' is transparently translated to the native newline sequence used by the system, which may be longer than one character. (Note that a C implementation is

How to create a temporary file with portable shell in a secure way?

南笙酒味 提交于 2019-12-03 12:46:24
I want to create a temporary file in POSIX shell ( /bin/sh ). I found out that mktemp(1) doens't exist on my AIX box, and according to How portable is mktemp(1)? , it isn't that portable and/or secure anyway. So, what should I use instead ? billhill00 Why not use /dev/random ? It could be neater with perl but od and awk will do, something like: tempfile=XXX-$(od -N4 -tu /dev/random | awk 'NR==1 {print $2} {}') ghoti You didn't exactly define "secure", but one element of it is probably to clean up after yourself. trap "rm -f \"$tmpfile\"" 0 1 2 3 15 You can probably man 3 signal to see if there

Cross-platform primitive data types in C++

穿精又带淫゛_ 提交于 2019-12-03 12:29:53
Unlike Java or C#, primitive data types in C++ can vary in size depending on the platform. For example, int is not guaranteed to be a 32-bit integer. Various compiler environments define data types such as uint32 or dword for this purpose, but there seems to be no standard include file for fixed-size data types. What is the recommended method to achieve maximum portability? I found this header particularly useful: BOOST cstdint Usually better than inventing own wheel (which incurs the maintenance and testing). Create a header file called types.h, and define all the fixed-size primitive types

Portable C binary serialization primitives

本小妞迷上赌 提交于 2019-12-03 12:11:13
As far as I know, the C library provides no help in serializing numeric values into a non-text byte stream. Correct me if I'm wrong. The most standard tool in use is htonl et al from POSIX. These functions have shortcomings: There is no 64-bit support. There is no floating-point support. There are no versions for signed types. When deserializing, the unsigned-to-signed conversion relies on signed integral overflow which is UB. Their names do not state the size of the datatype. They depend on 8-bit bytes and the presence of exact-size uint_ N _t. The input types are the same as the output types

How are PE Base Relocations build up?

丶灬走出姿态 提交于 2019-12-03 10:39:01
问题 I'm currently having trouble understanding how PE Base Relocations are build up. I understand there can be more then one relocation, I understand also why and how this is done, but I just don't understand it programmatically: Which of the following is true (IMAGE_BASE_RELOCATION in WinNT.h)? // Base relocation #1 DWORD VirtualAddress; DWORD SizeOfBlock; // size of current relocation WORD TypeOffset[1]; // Base relocation #2 DWORD VirtualAddress; DWORD SizeOfBlock; // size of current

int vs size_t on 64bit

为君一笑 提交于 2019-12-03 10:18:31
Porting code from 32bit to 64bit. Lots of places with int len = strlen(pstr); These all generate warnings now because strlen() returns size_t which is 64bit and int is still 32bit. So I've been replacing them with size_t len = strlen(pstr); But I just realized that this is not safe, as size_t is unsigned and it can be treated as signed by the code (I actually ran into one case where it caused a problem, thank you, unit tests!). Blindly casting strlen return to (int) feels dirty. Or maybe it shouldn't? So the question is: is there an elegant solution for this? I probably have a thousand lines

How to do portable 64 bit arithmetic, without compiler warnings

半世苍凉 提交于 2019-12-03 10:12:57
I occasionally use 64 bit arithmetic in an open source C++ library of mine. I discovered that long long serves my purpose quite nicely. Even some 10 year old solaris box could compile it. And it works without messing around with #defines on Windows too. Now the issue is I get complaints from my users because they compile with GCC -pedantic settings, and GCC insists on issuing warnings that long long is not part of the C++ standard. This is probably right, but I am not too interested in the C++ standard per se, I just want my code to work on as many compilers as reasonably possible. So my