I would love to have autocomplete in macros like for example,
#ifdef DEBUG
static void print_debug_info(object obj) {
...
}
#endif
Using a near-default configuration of AppCode, it doesn't appear this is enabled. Is there anyway to enable it?
Related
I'm building an app for Android and iOS and I want to reuse as much code as possible. I have some generic C code (an algorithm) that doesn't include any system library. Is it possible to expose it to my common Kotlin source set using cinterop or any other tool?
My build.gradle.kts:
plugins {
id("com.android.library")
kotlin("multiplatform")
kotlin("native.cocoapods")
}
android {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
}
sourceSets.all {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
java.srcDirs("src/androidMain/java")
res.srcDirs("src/androidMain/res")
}
}
version = "1.0"
kotlin {
android()
ios()
cocoapods {
// Configure fields required by CocoaPods.
summary = "..."
homepage = "..."
// You can change the name of the produced framework.
// By default, it is the name of the Gradle project.
frameworkName = "SharedModule"
}
// Workaround for ios platform imports to work on Android Studio
// iosX64("ios")
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
}
sourceSets["androidMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
sourceSets.all {
languageSettings.progressiveMode = true
}
}
Not automatically. On the JVM side you'll need to use JNI to talk to the C code, and on the native side you'll need to use Kotlin cinterop. JNI and Kotlin cinterop will have an interface to the C code that's very similar to each other, but not the same. To expose that to common code, you'll need to write a common API layer that delegates to JNI code on the JVM and Kotlin cinterop code on native.
Wrapping very similar platform-specific API's is pretty straightforward once you get used to it. Ideally, you could automatically wrap them, but right now you can't. I gave a talk that discusses some techniques for this: https://vimeo.com/371460823
Below follows a simple example of how to call c code within Kotlin:
cCaller.kt
class cCaller {
init {
System.loadLibrary("cCode")
} external fun callCFunction()
}
In your code:
fun main() {
cCaller().callCFunction()
}
cCode.c
#include <stdio.h>
#include "cCaller.h"JNIEXPORT void JNICALL Java_cCaller_callCFunction(JNIEnv *env, jobject obj) {
// YOUR CODE HERE
return;
}
Notice that the function callCFunction is prefixed with Java_ and cCaller_
Also notice the #include "cCaller.h" added to the second line of cCode.c - we need to create this file:
cCaller.h
#include <jni.h>#ifndef _Included_NativeSample
#define _Included_NativeSample
#ifdef __cplusplus
extern "C" {
#endifJNIEXPORT void JNICALL Java_cCaller_callCFunction(JNIEnv *, jobject);#ifdef __cplusplus
}
#endif
#endif
Compile
gcc cCode.c -o libcCode.so -shared -fPIC -I <jdk_path>/include -I <jdk_path>/include/linux
Using Clangformat
I currently have the following method:
- (void)myMethod
{
#if DEBUG
[ClassMethod enableLogging];
#endif
}
I wish for it to be displayed as so
- (void)myMethod
{
#if DEBUG
[ClassMethod enableLogging];
#endif
}
Any ideas?
LVVM Research Link
Anyone know of a way of getting rid of the "empty block should be documented" warning in generated files when using ANTLR. I know I can disable the warning in Eclipse but I would like to keep it enabled and I like having a clean compile.
PathBaseListener.java
#Override public void enterPath(#NotNull PathParser.PathContext ctx) { }
So I think, you have to insert a command. E.g.:
#Override
public void enterPath(#NotNull PathParser.PathContext ctx){
/* not implemented */
}
I'm currently working on a project using Borland C++, I have two Forms so far but each one in an independent Project, I wish to join these two project into one project so I can switch between the Forms.
I want to have only one executable file (for security purposes), I tried reading some pdfs about borland c++, also tried googling it, but no luck.
if there's a way to do so, I wish you could guide me or give me some hints.
Note: I'm using Borland C++ Builder 6, under Windows 8.1.
I am used to BDS2006 so for newer IDE/Compilers it can be different
1.form copy
has .h,.cpp,*.dfm files
copy them to target project directory
2.open target project in IDE
3.add forms to project
find add to project in IDE main menu (I think it is in Project tag)
then select *.dfm files of your new forms click add or OK ...
4.Open target project source code (*.cpp)
should look like this:
//$$---- EXE CPP ----
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
//*** here you have line for each form type and its name in forms menu
USEFORM("win_view.cpp", win_view);
USEFORM("win_main.cpp", win_main);
USEFORM("win_editor\win_editor_setup.cpp", win_EditorSetup);
USEFORM("win_editor\win_editor.cpp", win_editor);
USEFORM("win_editor\win_editor_find.cpp", win_EditorFind);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
//*** here create form for each static form you want
//*** dynamic windows (created in runtime are not here !!!
Application->CreateForm(__classid(Twin_main), &win_main);
//*** here load cross references to forms if needed
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
5.dynamic forms
add #include of *.h for all dynamic/used inside form files to main form cpp file
this makes them accessible from main form
now you can crete / destroy windows
should look like this:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "win_main.h"
//*** add the dynamic/used forms *.h files
#include "win_view.h"
#include "win_editor\win_editor.h"
//---------------------------------------------------------------------------
//*** add pointer to dynamic forms
Twin_view *win_view=NULL;
//---------------------------------------------------------------------------
void __fastcall Twin_main::some_event(...)
{
win_view=new Twin_view(win_main);
if (win_view)
{
win_view->OnResize(win_view);
win_view->_can_close=false;
}
}
//---------------------------------------------------------------------------
void __fastcall Twin_main::FormDestroy(TObject *Sender)
{
//*** destroy form before exiting also can call ->Close() and wait few [ms] before
if (win_view) { delete win_view; win_view=NULL; }
}
//-------------------------------------------------------------------
you can also move the form pointers to owner form class to make it more objective c++ like
and allow to make multiple originaly main forms in future (in another project later)
6.static used forms
just include *.cpp file instead of *.h
the pointer to these forms are directly in *.cpp files (at the start)
[notes]
if your forms have some global variables
then you can not use more then 1 form of that type
also the global variable names have to be different between used forms
do not change namespace for them it will make VCL crazy
For example, #ifdef iOS, #ifdef android, or the like. If there is #if, that would be even better.
iOS:
#if __MOBILE__
Console.WriteLine ("__MOBILE__ is defined");
#endif
#if __IOS__
Console.WriteLine ("__IOS__ is defined");
#endif
Android:
#if __MOBILE__
Console.WriteLine ("__MOBILE__ is defined");
#endif
#if __ANDROID__
Console.WriteLine ("__ANDROID__ is defined");
#endif
https://bugzilla.xamarin.com/show_bug.cgi?id=6459#c12
xamarin documentation
Yes it does, I don't know, if Xamarin.iOS provides its own symbols, as I'm new to Xamarin and I actually do not use Xamarin.iOS, but you can define your own symbols.
Right click on the project an open the project options. In the "Compiler" settings you can lookup existing flags and create add new ones.
For example here are the symbols that are shipped with Xamarin.Android:
DEBUG;__MOBILE__;__ANDROID__;
The flags should be available immediately after you have defined them.