Is it possible to use rb_cIPSocket in ruby C extension - ruby

I am learning how to write Ruby C extensions and I'm past the simplest examples. I was trying to achieve something with sockets so I attempted to create an extension which would define a class under rb_cIPSocket.
At the top of my C file I have:
#include "rubysocket.h"
And I am receiving:
...s.c:3:31: error: rubysocket.h: No such file or directory
Which is most probably the case. However, I tried all possible paths:
#include "rubysocket.h"
#include "socket/rubysocket.h"
#include "ext/socket/rubysocket.h"
#include <rubysocket.h>
#include <socket/rubysocket.h>
#include <ext/socket/rubysocket.h>
And this is my extconf.rb:
require 'mkmf'
dir_config("my_ext")
have_library("c", "main")
create_makefile("my_ext")
And so on. What am I actually missing here? Why can't I include that header file?
I am using OSX with RVM and Ruby 1.9.3-p448.
Thank you.

where does rubysocket.h live? If it's in the heart of ruby's source code then odds are it is "private" for ruby's use, but you can look it up like...
VALUE ipSocketClass = rb_const_get("IPSocket");
or the like.
GL!

Related

Why can't I set the full path inside angle brackets of the #include directive in Inno Setup?

Why does Inno Setup treat the following line as an error:
#include <C:\ABOfficeProjects\Install\InnoSetupProject\VCL_Styles\VCL_Styles.iss>
Why can't I use angle brackets like this?
That problem turned to be a syntax highlighter bug which I've created a report for.
Here's the link: https://groups.google.com/g/innosetup/c/oZ87CLZyOXM

Setting sdkconfig using platform.io for the ESP32

I was wondering if anybody managed to set the SDKConfig.h file for the ESP32 when using platform.io to upload code, and if so how it is done.
Thanks in advance!
✌️
You can copy and modify the file SDKConfig.h into your project include folder from:
/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config/
or paste "CONFIG_ULP_COPROC_RESERVE_MEM" in your code and <Ctrl+LClick> to go to this file in your system.
And add this to your platformio.ini so that the file in your project has priority
build_flags =
-Iinclude
Tested with framework-arduinoespressif32 Version 3.10006.210326 (1.0.6)
Let me know if it works for you, I'm guessing it could work with the other frameworks?
if some of the definitions gives you a problem because they are defined elsewhere just add a guard like this:
#ifndef CONFIG_FLASHMODE_DIO
#define CONFIG_FLASHMODE_DIO 1
#endif

where is the interface header file of HIDL in AOSP?

I studied the HIDL using Nfc code in AOSP .
As i know, when INfc.hal is compiled, INfc.h is autogenerated like following picture.
In NxpService.cpp, there is code like following
#include <android/hardware/nfc/1.1/INfc.h>
But, I couldn't find that path.
where is the real path of android/hardware/nfc/1.1/INfc.h?
In addition, I became curious how gcc compile works in NxpService.cpp that uses INfc.h.
Could you explain how gcc compiler can find INfc.h and work without compile error?
INfc.hal
Path: /hardware/interfaces/nfc/1.1/INfc.hal
Android.bp
hidl_interface {
name: "android.hardware.nfc#1.1",
root: "android.hardware",
NxpService.cpp
Path: /hardware/nxp/nfc/1.1/NxpService.cpp
#include <android/hardware/nfc/1.1/INfc.h>
...
int main(){
sp<INfc> nfc_service = new Nfc();
status_t status = nfc_service->registerAsService();
android.hardware.nfc#1.1 would be at hardware/interfaces/nfc/1.1/ here.
The mappings for Android provided interfaces to their actual location are shown here https://source.android.com/devices/architecture/hidl/interfaces.
The files you look for are all auto-generated by hidl-gen, and they usually locate in out directory, e.g.
$ANDROID_ROOT/out/soong/.intermediates/hardware/interfaces/nfc/1.1/android.hardware.nfc#1.1_genc++_headers/gen/android/hardware/nfc/1.1

Foundation.h on Windows

I know these questions have been asked before but everything suggest using GNUStep. Is there a way to use Foundation without GNUStep? This is also a learning question for me (like if it's possible to do by linking files or something)
I have Cygwin and gcc installed. I got all the Libraries from CocoaTron as in here: http://code.google.com/p/cocotron/source/browse/
I added the library folder to the OBJC_INCLUDE_PATH and the C_INCLUDE_PATH and it doesn't complain about not being able to find Foundation.h anymore.
But I get other errors like:
$ gcc intro.m -o intro
In file included from /cocoa/CoreFoundation/CFBase.h:144,
from /cocoa/CoreFoundation/CFAttributedString.h:8,
from /cocoa/CoreFoundation/CoreFoundation.h:42,
from /cocoa/Foundation/Foundation.h:37,
from car.h:1,
from intro.m:2:
/cocoa/CoreFoundation/CFString.h:88: error: parse error before "va_list"
In file included from /cocoa/Foundation/NSAffineTransform.h:9,
from /cocoa/Foundation/Foundation.h:41,
from car.h:1,
from intro.m:2:
/cocoa/Foundation/NSGeometry.h:9:32: Foundation/NSObject.h: No such file or directory
In file included from /cygdrive/d/Allebrum Resources/C Libraries/cocoa/Foundation/NSAffineTransform.h:9,
from /cygdrive/d/Allebrum Resources/C Libraries/cocoa/Foundation/Foundation.h:41,
from car.h:1,
from intro.m:2:
I'm sorry for the novice question, I was just interested in running a few test and didn't want to install GNUStep.
I mean, a really simple example like:
//car.h
#import <Foundation/Foundation.h>
#interface Car : NSObject{
}
- (void)addGas;
#end
#include <stdio.h>
#import "car.h"
int main(int argc, const char * argv[]){
printf("Hello");
return 0;
}
Yes, I know this example doesn't need objC ;) I was just trying to follow along with a tutorial.
Thanks for the help!
Looking at the Cocotron's requirements page and general information page, it seems that it only supports development on the Mac. What it provides is the ability to build a Windows- or Linux-compatible product… on your Mac.
So, as far as I can tell, at this time, you can't use Cocotron to develop on Windows. You'll still have to use GNUstep.

namespace over a #include header file question

I porting code from a windows machine to a Mac. I am using OS X 10.6 with Xcode 3.2.5
I have a header file called api.h which has the following code:
namespace ocip {
#include "onan/ocip/ocip.h"
}
ocip.h includes #include stdint.h
which has the following typedef:
typedef unsigned int uint32_t;
Now back to api.h I have class with following in it:
ocip::uint32_t m_nMode;
The compiler tells me that uint32_t in namespace 'ocip' does not name a type.
Any ideas what I am doing wrong?
I don't know if this will help, but a type of "uint32_t" may already be declared. There is already a typedef of the same name if you are including "stdint". This could be causing a problem with redefining it in opic.h.

Resources