Compile and run same code on different versions of XCode to target different iOS versions - ios6

My app was previously coded in XCode 4.5, now for iOS7 compatibility, I'm coding it into XCode 5.0, have added some code, that start support from iOS7 only. At the same time I need to run it back on XCode 4.5, now here it'll show error because that particular code not available in iOS < 7.0.
E.g.
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0")) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
There's no issue when I compile it with XCode 5.0 but showing error when compile in XCode 4.5, I know the reason -- that is,UIStatusBarStyleLightContent is available from iOS7 only, and iOS7 is starting support from XCode 5.0 onwards, but I want a solution that this code won't affect if its not support for particular iOS target?
Something like,
if(NOT_SUPPORTED_IOS) {
//NO NEED TO COMPILE THIS LINE or THIS LINE WONT EXECUTE
}

You can use conditional compiling to handle such cases:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 // iOS 7.0 supported
// iOS 7 code here
#else
// Pre-iOS 7 code here
#endif
When you compile under Xcode 5, you will be compiling against the iOS 7 SDK: in such case, the first branch is used. When you compile under Xcode 4.5, you will be using an older SDK version and the second branch will be used.
Notice the use of precompiler #if/#endif: this will effectively make code visible or not visible to the compiler.
This will only fix the issue at compile time. But you still have another issue to consider: when your Xcode 5 built app will be run on an, e.g., iOS 6 device. In this case you app will crash, because of the use of the iOS 7-only feature. So you also need a runtime guard like:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
In your case, this would give:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 // iOS 7.0 supported
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
else
#endif
[UIApplication sharedApplication].statusBarStyle = ...;

Related

c++ exit crash Android Studio

Please help.
After exit(0), LogCat produces an error.
When I try to start the application again, I cannot.
It is not a program I created and I am not familiar with it.
How can I improve it?
Taskkill, force stop, same.
int programname ::endCommand()
{
quit();
stopSMPEG();
exit(0); //error
return RET_CONTINUE; // dummy
}
//Logcat error
2022-07-22 14:45:36.441 23989-24119/jp.**
A/libc: FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x708caf8f80)
2022-07-22 14:45:36.441 23989-24120/jp.**
A/libc: FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x708caf8f80)
2022-07-22 14:45:45.500 23989-24120/jp.**
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24120 (hwuiTask1), pid 23989 (**)
Android Studio 2021.2.1.15
Android API 31
SDK Tools
Android SDK Build Tools 33.0.0
NDK (Side by side) 21.4.7075529
Android Emulator 31.2.10
Android SDK Platform-Tools 33.0.2
Google Play Licensing Library 1

connect QT 5.3 and postgresql

I'm a newbie in Qt (although I have some experience with C/C++/Java/PHP). I'm trying to migrate my older program that use PostgreSQL database into Qt GUI. I'm using PostgreSQL v2 and have downloaded the recent QT 5.3.0 (for MinGW 32-bit).
I created an example widget application, called Anu. The Anu.pro file looks like this :
QT += sql
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Anu
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
And the mainwindow.cpp looks like this :
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSqlDatabase>
#include <QtSql>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("basicaccount");
db.setUserName("postgres");
db.setPassword("root");
db.setPort(5435);
bool ok = db.open();
if(ok != true)
{
QMessageBox::information(this,"Connection","Connection Failed!") ;
}
else
{
QMessageBox::information(this,"Connection","Connection OK!") ;
QSqlQueryModel model;
model.setQuery("select * from invoice ");
//ui->tableView->setModel(&model);
QMessageBox::information(this,"Information","This Message box is needed in order to see the rendered tableview!") ;
}
}
The error in compile shows QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7. I tried to build the plugin using the information here : http://qt-project.org/doc/qt-5/sql-driver.html. I opened the command prompt for Qt and put this :
cd E:\Qt\Qt5.3.0\5.3\mingw482_32\plugins\sqldrivers\psql
qmake "INCLUDEPATH+=E:\Program Files\PostgreSQL\9.2\include" "LIBS+=E:\Program Files\PostgreSQL\9.2\lib\libpq.lib" psql.pro
nmake
The problem is, I can't find the src folder or psql on folder sqldrivers. I've only found qsqlpsql.dll on that folder, and everytime I used it it says directory can't be found. Also, what's 'psql.pro' mean?
Thanks a lot for any help.
The most easy way, you need the following;
Depending on your application, 64 or 32 bit
If postgresql is 64 or 32 bit it doesn't matter, as the mingw is configured for 32 bit applications.
You need the 32 bit dlls,
If your version of postgre is 32 bit, then copy following dll's from your postgresql installations bin folder libeay32.dll, libintl.dll, libpq.dll, and ssleay32.dll, to your qt version mingw bin folder, now your program should work
If postgresql is 64 bit, the the included dll's doesn't work out of the box these are 64 bit !
You can still use 64 bit postgresql DB, no problem but you need the 32 bits dll's for your application.
There are more sophisticated ways to do this but to kick start your application this is considered the fastest.

NixOS nVidia Driver Version Bounds

I'm trying to get NixOS to work with my old GeForce 6600, which only accepts an nVidia driver version <305 (304.xx). Is there any way to put an upper bound on the kernel module version / proprietary version in my configuration.nix? Any help would be greatly appreciated!
You have to use nvidiaLegacy304 instead of nvidia in the system.xserver.videoDrivers = [ "nvidia..." ]; declaration (use hardware.opengl.videoDrivers for the unstable channel).

Writing R extensions in C (SHMGET crash in C)

I try to create a shared memory about cygwin in a Windows 7 environment. I compile it as normal c-program, all is working fine. If I try to call the function as R-Extension, the shmget-function is going crashed. The next step is to use semaphore. I hope this will run as well, if I solve this problem.
Is there any compiler option or something like else what I have to do? Maybe, have I to change the mingw to cygwin in R or what can I do. I'm really frustrated!
Actually I try to compile the extension with:
R CMD SHLIB wrappers.c IPC.c -Wall -pthread
And this is the problem child:
_smID = shmget(SHAREDMEMORYID, sizeof(struct sSharedMemory), IPC_CREAT |0666);
My R version:
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 1.0
year 2014
month 04
day 10
svn rev 65387
language R
version.string R version 3.1.0 (2014-04-10)
nickname Spring Dance
cygwin is up to date.

jad and jar size do not match in j2me

I am using N97 and Nokia 5530 for my application. More often whenever I install my application. I find this error. I have searched the internet and found a number of ways to solve this problem. I did use them such as check size of jar and the one written in jad and corrected it but still problem is not solved.
How can I remove this error in my build. Any help in this regard is highly appreciated.
I have read the stuff--- Unification of .jar and .jad files in a J2ME application --- but today devices and internet are much faster. Can't we ignore the creation of jad file.
EDIT
Following are jad and manifest attributes. I am using NetBeans 6.9 and Nokia S60 5th Edition SDK to generate and build the MIDlet.
jad attributes are as follows
Backkey: -11
LGE-MIDlet-Height: 400
LGE-MIDlet-Target-LCD-Height: 400
LGE-MIDlet-Target-LCD-Width: 240
LGE-MIDlet-Width: 240
LeftSoftKey: -6
MIDlet-1: MyAppName,/icon.png,com.main.MainMidlet
MIDlet-Jar-Size: 964642
MIDlet-Jar-URL: MyAppName.jar
MIDlet-Name: MyAppName
MIDlet-Permissions: javax.microedition.io.Connector.http
MIDlet-Touch-Support: true
MIDlet-Vendor: www.MyApp.com
MIDlet-Version: 1.4
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
Navi-Key-Hidden: true
Nokia-MIDlet-App-Orientation: portrait
Nokia-MIDlet-On-Screen-Keypad: no
RightSoftKey: -7
UseNativeTextButton: true
and Manifest attributes are
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.0
Created-By: 1.6.0_21-b06 (Sun Microsystems Inc.)
MIDlet-1: MyAppName,/icon.png,com.main.MainMidlet
MIDlet-Permissions: javax.microedition.io.Connector.http
MIDlet-Vendor: www.MyApp.com
Nokia-MIDlet-App-Orientation: portrait
LGE-MIDlet-Height: 400
Nokia-MIDlet-On-Screen-Keypad: no
MIDlet-Name: MyAppName
Navi-Key-Hidden: true
MIDlet-Touch-Support: true
LGE-MIDlet-Width: 240
MIDlet-Version: 1.4
Backkey: -11
LeftSoftKey: -6
UseNativeTextButton: true
LGE-MIDlet-Target-LCD-Height: 400
RightSoftKey: -7
LGE-MIDlet-Target-LCD-Width: 240
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
The only thing I can think of is that I usually see MIDlet-Jar-Size in the manifest, not in the jad.
Unfortunately, I never figured out how the build system managed to insert it in a compressed file (jars are basically zip files) and I don't know how to tell Netbeans to move the property from the jad to the manifest.
I was under the impression that if you ask Netbeans to generate a simple HelloWorld MIDlet and don't modify the ant script, MIDlet-Jar-Size ends up in the manifest.
I do think there is a relation between the property and the MIDlet being signed. It may act as a checksum.

Resources