Skip to content

Instantly share code, notes, and snippets.

@sherjilozair
Last active May 5, 2018 19:43
Show Gist options
  • Save sherjilozair/e289e46961169d1b883b1c93a81965f4 to your computer and use it in GitHub Desktop.
Save sherjilozair/e289e46961169d1b883b1c93a81965f4 to your computer and use it in GitHub Desktop.
#include "animal.h"
void Animal::inc(int i){
this->counter += i;
}
void Animal::say(){
std::cout << this->counter << std::endl;
}
#include <iostream>
class Animal
{
public:
int counter;
void inc(int);
void say();
};
main.nim(14) main
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
{.compile: "/Users/sherjilozair/NimProjects/nim-sfml/animal.cpp".}
const header = "/Users/sherjilozair/NimProjects/nim-sfml/animal.h"
type
AnimalObj {.header: header, importcpp: "Animal".} = object
Animal = ptr AnimalObj
proc say(animal: Animal) {.importcpp: "#.say(@)".}
proc inc(animal: Animal, i: cint) {.importcpp: "#.inc(@)".}
when isMainModule:
var x: Animal
x.say()
x.inc(10)
x.say()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment