stray '#' in program - macos

I want to use NSRunningApplication in my Qt application on Mac OS X.
I tried to include these header files in mainwindow.cpp:
#include Cocoa/Cocoa.h
#include Foundation/Foundation.h
#include AppKit/NSRunningApplication.h
#include AppKit/NSWorkspace.h
#include ApplicationServices/ApplicationServices.h
#include "CGWindow.h".
Also included following in .pro file
INCLUDEPATH += /System/Library/Frameworks/Foundation.framework/Headers
But this gives error: stray '#' in program
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6,
/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:8 : error: stray '#' in program.
My question is:
How to use NSRunningApplication in my application?
Which file(s) to include and where/how to remove these errors?

You need to make an objc file instead. Change the extension to .mm and use objc directive to import framework:
#import <Foundation/Foundation.h>

Related

How do I correctly set up WXWidgets on Ubuntu? My editor tells me the header files are incorrect

I wanted to try out the WXWidgets Hello World example (https://docs.wxwidgets.org/latest/overview_helloworld.html) so I followed the recommended practice on the Downloads page and installed the WXGTK package for my distribution, Ubuntu, which appears to be libwxgtk3.0-gtk3-dev. After doing this, and copying the example code, g++ (installed from build-essentials) throws an error when I attempt to compile the program:
wxtest.cpp:4:10: fatal error: wx/wxprec.h: No such file or directory
4 | #include <wx/wxprec.h>
| ^~~~~~~~~~~~~
compilation terminated.
My editor (VSCode) also shows me an error: cannot open source file "wx/wxprec.h".
This appears to be related to the fact that the WXWidgets header files are installed to the folder wx-3.0/wx instead of wx, but after changing #include <wx/wxprec.h> to #include <wx-3.0/wx/wxprec.h> I still get an error:
In file included from wxtest.cpp:4:
/usr/include/wx-3.0/wx/wxprec.h:12:10: fatal error: wx/defs.h: No such file or directory
12 | #include "wx/defs.h"
| ^~~~~~~~~~~
compilation terminated.
What am I doing wrong? How can these files be put in the right place?
See the building your project section of the docs.

Ruby's native header files are giving me an error

When I include in my native C extension for a gem that I am writing, I get the following error:
../../../../ext/my_file/my_file.c:4:42: error: unknown type name 'RUBY_T_FIXNUM'
Here is where I use it in my code:
#include <stdlib.h>
#include <ruby-2.3.0/ruby.h>
void my_file_init(const T_STRING prog, T_FIXNUM verbose) {}
I added a link in /usr/local/include to ~/.rvm/rubies/default/include/ruby-2.3.0, which is where I have the version of ruby that I want to use installed. The only definition I could find for the T_FIXNUM constant in the ruby header files was within an enum in ruby/ruby.h:
enum ruby_value_type {
...
RUBY_T_FIXNUM = 0x15
};
Here is where the ruby/ruby.h file defines the T_FIXNUM type:
#define T_FIXNUM RUBY_T_FIXNUM
Am I including files incorrectly? Do I have the wrong version of Ruby? I'm working on OSX and I use RVM to manage my rubies. I have added symbolic links for config.h in the x86_64-darwin16/ruby dir, as well as a link from the ruby dir to itself.

Undefined symbol after library search - CLIPPER

I have tried to compile an application written in Clipper 5.2.
It is experiencing an error which I believe is the inclusion of libraries.
The moment that I linked, it displays the following error:
I'm using: rtlink fi MyApp
Stretch of code where I import libraries:
#include "INKEY.CH"
#include "GRUMP.CH"
#include "BOX.CH"
#include "GRUMPBRO.CH"
#include "BOXGET.CH"
REQUEST dbfcdx
function Weekextr()
enter code here
Someone with knowledge clipper could help me?

Cannot open include file: iwscapi.h

I am trying to build an application that requires iwscapi.h. I am getting error:
"Cannot open include file: 'iwscapi.h': No such file or directory".
Below are my includesthat I have used:
#include <stdio.h>
#include <atlbase.h>
#include <atlstr.h>
#include <wscapi.h>
#include <iwscapi.h>
I have added Wscapi.lib in the linker. My build machine is Windows 7 and I am using VS2005 compiler. I manually searched the file iwscapi.h in C drive but it is missing.
Please let me know what causing this error.
Thanks in advance.

Qt5 application compiles on Linux and Windows, but gives cryptic error on Mac OS X

I work on a small open source pc timer project. I'd love to get my client working on OS X, but I can even get it to launch! I installed xcode, and the qt5 sdk with qtcreator. When I compile I get the following warnings, but the binary compiles:
/Users/kylehall/Documents/Libki/main.cpp:25: In file included from ../Libki/main.cpp:25:
/Users/kylehall/Documents/Libki/timerwindow.h:20: warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
#ifndef TIMERWINDOW_H
^~~~~~~~~~~~~
/Users/kylehall/Documents/Libki/timerwindow.h:21: 'LOGINWINDOW_H' is defined here; did you mean 'TIMERWINDOW_H'?
#define LOGINWINDOW_H
^~~~~~~~~~~~~
TIMERWINDOW_H
/Users/kylehall/Documents/Libki/timerwindow.cpp:21: In file included from ../Libki/timerwindow.cpp:21:
/Users/kylehall/Documents/Libki/timerwindow.h:20: warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
#ifndef TIMERWINDOW_H
^~~~~~~~~~~~~
/Users/kylehall/Documents/Libki/timerwindow.h:21: 'LOGINWINDOW_H' is defined here; did you mean 'TIMERWINDOW_H'?
#define LOGINWINDOW_H
^~~~~~~~~~~~~
TIMERWINDOW_H
/Users/kylehall/Documents/build-Libki-Desktop_Qt_5_2_1_clang_64bit-Debug/moc_timerwindow.cpp:9: In file included from moc_timerwindow.cpp:9:
/Users/kylehall/Documents/Libki/timerwindow.h:20: warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
#ifndef TIMERWINDOW_H
^~~~~~~~~~~~~
/Users/kylehall/Documents/Libki/timerwindow.h:21: 'LOGINWINDOW_H' is defined here; did you mean 'TIMERWINDOW_H'?
#define LOGINWINDOW_H
^~~~~~~~~~~~~
TIMERWINDOW_H
When I try to run the binary I get the following error:
dyld: Library not loaded: /work/build/______________________________PADDING______________________________/lib/QtPositioning.framework/Versions/5/QtPositioning
Referenced from: /Users/kylehall/Documents/build-Libki-Desktop_Qt_5_2_1_clang_64bit-Debug/libkiclient.app/Contents/MacOS/libkiclient
Reason: image not found
Debugging has finished
At this point I don't even know where to begin with such a cryptic error. Any suggestions would be great! You can grab the code and try compiling it yourself from https://bitbucket.org/libki-kms/libki-client/src
Seems pretty clear:
warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
So you must have:
#ifndef TIMERWINDOW_H
#define LOGINWINDOW_H
Copy and paste error, I'd say...

Resources