error: unknown type name ‘mxArray’ - matlab

When I try to use MATLAB mex command to compile a c file, I met the following error
error: unknown type name ‘mxArray’
The error code is here
const char *model_to_matlab_structure(mxArray *plhs[], int num_of_feature, struct svm_model *model);
struct svm_model *matlab_matrix_to_model(const mxArray *matlab_struct, const char **error_message);
I don't understand why MATLAB doesn't recognize the mxArray type. How could I resolve this? Thanks!

Thanks. It turns out that I forgot
#include "mex.h"

Related

Error not a valid device model name in Qemu

I am trying to add a custom device in Qemu source code.
Below are the steps which I followed to add a device in Qemu source code:
Go to directory where qemu is installed
Then
created a custom device file in hw/misc/.c
created a entry in qemu/hw/misc/Makefile.objs
created a entry in qemu/config-all-devices.mak
created a entry in qemu/arm-softmmu/config-devices.mak
created a entry in qemu/arm-softmmu/config-devices.mak.old
After I run below two commands
sudo make CFLAGS="-Wno-error"
sudo make install
Then I run qemu with my custom device
Below is the script to run qemu
#!/bin/bash
KERNEL="/lhome/priyamvad/debian_qemu_arm32/vmlinuz-3.16.0-6-armmp-lpae"
INIT_IMAGE="/lhome/priyamvad/debian_qemu_arm32/initrd.img-3.16.0-6-armmp-lpae"
DISK="/lhome/priyamvad/debian_qemu_arm32/hda30.qcow2"
/lhome/priyamvad/arm_qemu_Setup/qemu/arm-softmmu/qemu-system-arm \
-M virt \
-m 1024 \
-smp 4 \
-kernel $KERNEL \
-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-device,rng=rng0 \
-initrd $INIT_IMAGE \
-append 'root=/dev/vda2' \
-drive if=none,file=$DISK,format=qcow2,id=hd \
**-device hello-world-device** \
-device virtio-blk-device,drive=hd \
-device virtio-net-device,netdev=usernet \
-netdev user,id=usernet,hostfwd=tcp::2222-:22 \
-nographic
When I run above script, I get following error:
ERROR:
qemu-system-arm: -device hello-world-device: 'hello-world-device' is
not a valid device model name
So what i am missing in above steps?
You're trying to edit some files which are autogenerated by the configure and make process, so when you run make your changes will be overwritten again: config-devices.mak, config-devices.mak.old and config-all-devices.mak are all autogenerated.
The place you want to put your new CONFIG_HELLO_DEVICE=y is in default-configs/arm-softmmu.mak. Then hw/misc/Makefile.objs can use it in a line like "common-obj-$(CONFIG_HELLO_DEVICE) += hello.o".
Check that your source file is actually getting compiled and linked into the QEMU binary when you run make. If it is, then the problem is something in your C sources; if it is not, then you haven't got your makefile/default-configs stuff right.
Some extra advice:
sudo make CFLAGS="-Wno-error" sudo make install
is a really bad way to do "compile QEMU for testing":
it's running the whole make process as root unnecessarily
it's doing an install, which you don't need to do to just run the QEMU binary you've built for testing
you're overriding the default "warnings are errors" setting, which is just hiding bugs in your code you need to fix (and if you really do need to do this for some reason, it's the wrong way to do it: there is a configure --disable-werror option)
it's doing a build in the source directory, which means that autogenerated files from the build get mixed in with the source files. This is why you got confused and tried to edit the autogenerated config-devices.mak files I think.
Upstream QEMU strongly recommends doing a build in a separate build directory (I give some plausible configure options but use what you want):
mkdir build
(cd build && ../configure --target-list=arm-softmmu --enable-debug)
make -j8 -C build
(You will need to do a 'distclean' on your current source tree to get rid of the results of the build-in-source-tree or just throw it away and start again to get to a clean state that you can then do an out-of-tree build from.)
Once you've done 'make' you can simply run the built qemu binary directly as ./build/arm-softmmu/qemu-system-arm.
I have tried the method you suggested for adding custom device to Qemu(arm-32bit) source code but it give following errors:
Added entry for my device in following file hw/misc/Makefile.objs and default-configs/arm-softmmu.mak
Run make by giving below commands
make distclean
make -j8 -C build
I am attaching below image to show output containing error
qemu-system-arm build error
After checking the output shown by above image, I created a file "config-devices.mak" in build/arm-softmmu.
I once again run commands described in step 2.
I get following output and error show below.
ERROR
ar: creating libfdt/libfdt.a
ar: creating /lhome/priyamvad/debian_qemu_arm32_updated/qemu/build/capstone/libcapstone.a
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:19:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/hw.h:8:20: error: expected \u2018=\u2019, \u2018,\u2019, \u2018;\u2019, \u2018asm\u2019 or \u2018__attribute__\u2019 before \u2018hw_error\u2019
void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
^~~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:7,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:19,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/hwaddr.h:11:9: error: unknown type name \u2018uint64_t\u2019
typedef uint64_t hwaddr;
^~~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:19,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:15:28: error: unknown type name \u2018CPUState\u2019
void tcg_flush_softmmu_tlb(CPUState *cs);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:37:9: error: unknown type name \u2018uintptr_t\u2019
typedef uintptr_t ram_addr_t;
^~~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:46:60: error: unknown type name \u2018uint32_t\u2019
typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:47:9: error: unknown type name \u2018uint32_t\u2019
typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:52:1: error: unknown type name \u2018RAMBlock\u2019
RAMBlock *qemu_ram_block_by_name(const char *name);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:53:1: error: unknown type name \u2018RAMBlock\u2019
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:53:47: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:55:39: error: unknown type name \u2018RAMBlock\u2019
ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:56:25: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:56:60: error: unknown type name \u2018DeviceState\u2019
void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
^~~~~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:57:27: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_unset_idstr(RAMBlock *block);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:58:32: error: unknown type name \u2018RAMBlock\u2019
const char *qemu_ram_get_idstr(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:59:30: error: unknown type name \u2018RAMBlock\u2019
void *qemu_ram_get_host_addr(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:60:32: error: unknown type name \u2018RAMBlock\u2019
ram_addr_t qemu_ram_get_offset(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:61:37: error: unknown type name \u2018RAMBlock\u2019
ram_addr_t qemu_ram_get_used_length(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:62:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool qemu_ram_is_shared(RAMBlock *rb);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:62:25: error: unknown type name \u2018RAMBlock\u2019
bool qemu_ram_is_shared(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:63:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:63:30: error: unknown type name \u2018RAMBlock\u2019
bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:64:31: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_set_uf_zeroable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:65:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool qemu_ram_is_migratable(RAMBlock *rb);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:65:29: error: unknown type name \u2018RAMBlock\u2019
bool qemu_ram_is_migratable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:66:30: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_set_migratable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:67:32: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_unset_migratable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:1: error: unknown type name \u2018size_t\u2019
size_t qemu_ram_pagesize(RAMBlock *block);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:1: note: \u2018size_t\u2019 is defined in header \u2018\u2019; did you forget to \u2018#include \u2019?
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:8:1:
+#include
#endif
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:1:
size_t qemu_ram_pagesize(RAMBlock *block);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:26: error: unknown type name \u2018RAMBlock\u2019
size_t qemu_ram_pagesize(RAMBlock *block);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:70:1: error: unknown type name \u2018size_t\u2019
size_t qemu_ram_pagesize_largest(void);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:70:1: note: \u2018size_t\u2019 is defined in header \u2018\u2019; did you forget to \u2018#include \u2019?
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:72:42: error: unknown type name \u2018uint8_t\u2019
void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
^~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h: In function \u2018cpu_physical_memory_read\u2019:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:77:5: error: implicit declaration of function \u2018cpu_physical_memory_rw\u2019; did you mean \u2018cpu_physical_memory_read\u2019? [-Werror=implicit-function-declaration]
cpu_physical_memory_rw(addr, buf, len, 0);
^~~~~~~~~~~~~~~~~~~~~~
cpu_physical_memory_read
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:77:5: error: nested extern declaration of \u2018cpu_physical_memory_rw\u2019 [-Werror=nested-externs]
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h: At top level:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:89:30: error: unknown type name \u2018QEMUBH\u2019; did you mean \u2018QEMU_HW_H\u2019?
void cpu_register_map_client(QEMUBH *bh);
^~~~~~
QEMU_HW_H
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:90:32: error: unknown type name \u2018QEMUBH\u2019; did you mean \u2018QEMU_HW_H\u2019?
void cpu_unregister_map_client(QEMUBH *bh);
^~~~~~
QEMU_HW_H
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:92:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool cpu_physical_memory_is_io(hwaddr phys_addr);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:103:32: error: unknown type name \u2018RAMBlock\u2019
typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:105:28: error: unknown type name \u2018RAMBlockIterFunc\u2019
int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
^~~~~~~~~~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:29: error: unknown type name \u2018RAMBlock\u2019
int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:43: error: unknown type name \u2018uint64_t\u2019
int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:59: error: unknown type name \u2018size_t\u2019
int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:59: note: \u2018size_t\u2019 is defined in header \u2018\u2019; did you forget to \u2018#include \u2019?
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:21,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memattrs.h:69:9: error: unknown type name \u2018uint32_t\u2019
typedef uint32_t MemTxResult;
^~~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/host-utils.h:29,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memop.h:15,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:22,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:87:9: error: unknown type name \u2018uint8_t\u2019
typedef uint8_t flag;
^~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:93:9: error: unknown type name \u2018uint16_t\u2019
typedef uint16_t float16;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:94:9: error: unknown type name \u2018uint32_t\u2019
typedef uint32_t float32;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:95:9: error: unknown type name \u2018uint64_t\u2019
typedef uint64_t float64;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:106:5: error: unknown type name \u2018uint64_t\u2019
uint64_t low;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:107:5: error: unknown type name \u2018uint16_t\u2019
uint16_t high;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:115:5: error: unknown type name \u2018uint64_t\u2019
uint64_t low, high;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:169:5: error: unknown type name \u2018uint8_t\u2019
uint8_t float_exception_flags;
^~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/host-utils.h:29,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memop.h:15,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:22,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:29:15: error: unknown type name \u2018uint16_t\u2019
static inline uint16_t bswap16(uint16_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:29:32: error: unknown type name \u2018uint16_t\u2019
static inline uint16_t bswap16(uint16_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:35:15: error: unknown type name \u2018uint32_t\u2019
static inline uint32_t bswap32(uint32_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:35:32: error: unknown type name \u2018uint32_t\u2019
static inline uint32_t bswap32(uint32_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:43:15: error: unknown type name \u2018uint64_t\u2019
static inline uint64_t bswap64(uint64_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:43:32: error: unknown type name \u2018uint64_t\u2019
static inline uint64_t bswap64(uint64_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:56:29: error: unknown type name \u2018uint16_t\u2019
static inline void bswap16s(uint16_t *s)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:61:29: error: unknown type name \u2018uint32_t\u2019
static inline void bswap32s(uint32_t *s)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:66:29: error: unknown type name \u2018uint64_t\u2019
static inline void bswap64s(uint64_t *s)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:142:15: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type endian ## size ## _to_cpu(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:142:46: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type endian ## size ## _to_cpu(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:147:15: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type cpu_to_ ## endian ## size(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:147:46: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type cpu_to_ ## endian ## size(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:152:47: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline void endian ## size ## _to_cpus(type *p)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:157:51: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline void cpu_to_ ## endian ## size ## s(type *p)\
Are the above errors due to bugs in qemu source code or I am doing something nasty?
Some description about my work
Creating a custom device in Qemu.
Creating a device driver to test custom device.
I have created custom device and now I want to run my custom device on Qemu
Qemu is imitating ARM(32 bit) hardware and running debian on it.
Is it necessary to create device driver for custom device or it can be tested by a user application ?
Code of files used
custom device source file
custom device
Makefile.objs source file
Makefile.objs
config-device.mak souce file
config-device.mak

How to solve: error C2039: 'make_normal_of_point_with_normal_pmap': is not a member of 'CGAL'

I am using CGAL 4.12 and eigen 3.3.4 and trying to compile the Poisson_surface_reconstruction_3 example trough a Matlab mex function and am getting the following error:
C:\Users\u0116401\Documents\PRosPeRoS\Matlab_Code\mexTest\CGAL_poisson_reconstruction.cpp(70): error C2039: 'make_normal_of_point_with_normal_pmap': is not a member of 'CGAL'
C:\dev\CGAL-4.12\include\CGAL/IO/read_xyz_points.h(40): note: see declaration of 'CGAL'
C:\Users\u0116401\Documents\PRosPeRoS\Matlab_Code\mexTest\CGAL_poisson_reconstruction.cpp(70): error C3861: 'make_normal_of_point_with_normal_pmap': identifier not found
It seems 'make_normal_of_point_with_normal_pmap' can't be found. Does anyone know what is causing this issue?
The code that produces this error is:
/* mex headers */
#include <mex.h>
/* C++ headers */
#include <vector>
#include <fstream>
/* CGAL headers */
#include <CGAL/trace.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Implicit_surface_3.h>
#include <CGAL/IO/output_surface_facets_to_polyhedron.h>
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/compute_average_spacing.h>
// Types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef CGAL::Point_with_normal_3<Kernel> Point_with_normal;
typedef Kernel::Sphere_3 Sphere;
typedef std::vector<Point_with_normal> PointList;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Poisson_reconstruction_function<Kernel>Poisson_reconstruction_function;
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
void mexFunction(int nlhs, mxArray *plhs[], /*Output variables */
int nrhs, const mxArray *prhs[]) /*Input variables */
{
PointList points;
std::ifstream stream("kitten.xyz");
if (!stream ||
!CGAL::read_xyz_points_and_normals(
stream,
std::back_inserter(points),
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))))
}
The function is named make_normal_of_point_with_normal_map() (map not pmap) and it takes Point_with_normal as parameter. The call should be:
CGAL::make_normal_of_point_with_normal_map(Point_with_normal())

Updateing code to swift 4 results in an error message

I wan to update this code to swift 4:
rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
return rc;
}
But I get two errors:
Declaration of 'select' must be imported from module 'Darwin.POSIX.sys.time' before it is required
Implicit declaration of function 'select' is invalid in C99
How can I can fix this?
Add this near the top of your file:
#include <sys/time.h>

How MATLAB mex files access MATLAB instances?

This is the entry point for every mex file:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
In fact mex files are windows dll files with mexFunction as the main function.
My question is when the mex function is called, how it can access matlab instance specific data from inside the mex. As an example, consider 'mexPutVariable' function. It's job is 'copy an array from inside MEX-function into the specified workspace (outside mex)'. But how it knows where is 'workspace'. No parameter has passed to mex (like a pointer), containing matlab instance data (caller). mex files know only nlhs, plhs, nrhs, prhs and none of them can help mex files to excavate matlab instance specific data(caller function information).
A possible solution is that "Matlab.exe" is declaring mexPutVariable as an exported function:
[Matlab.exe]
int __declspec(dllexport) mexPutVariable(const char* workspace, const char* name, const mxArray* parray)
{
...
}
It is then very easy to retreive this function from the dll using GetModuleHandle and GetProcAddress:
[Module.dll]
// Declare function pointer
int (*FctnPtr)(const char* workspace, const char* name, const mxArray* parray);
// Retreive the main executable
HANDLE hExe = GetModuleHandle(NULL);
// Link to exported function in the exe just like you would do for any dll
FctnPtr mexPutVariable = (FctnPtr)GetProcAddress(hExe, "mexPutVariable");
// Use exported function from the dll
mexPutVariable("Base", "foo", myArray);
For compiling the mex file and after looking at mex.h file, mexPutVariable is declared as an external function to link with:
LIBMWMEX_API_EXTERN_C int mexPutVariable(const char* workspace, const char* name, const mxArray* parray);
Which turn to be simply (when compiled as dll side):
extern "C" int mexPutVariable(const char* workspace, const char* name, const mxArray* parray);

Compiler Warning libpcap

Having followed the examples http://www.tcpdump.org/pcap.htm, and exploring the documentation, I can't see what I have done wrong with the following code
// main.c
void got_packet(u_char *args, struct pcap_pkthdr *header, const u_char *packet);
/// ...snip...
void got_packet(u_char *args, struct pcap_pkthdr *header, const u_char *packet) {
printf("Received Packet\n");
}
/// ...snip...
pcap_dispatch(handle, 100, got_packet, NULL);
to warrant the compiler warnings that I am seeing:
gcc -g -O3 -I../sensor/ -c -o sensordatad.o sensordatad.c
main.c: In function ‘start_capture’:
main.c:96:27: warning: initialization from incompatible pointer type [enabled by default]
main.c:146:3: warning: passing argument 3 of ‘pcap_dispatch’ from incompatible pointer
type [enabled by default]
It might be that I'm being too fussy, it seems like every other piece of C code I have ever seen has a page full of compiler warnings when compiling, but I want to at least finish this code without warnings!
I've also tried doing this, to somehow typecast the function pointer, something I hadn't seen in any of the examples; but I felt it worth a shot:
pcap_handler callback = &got_packet;
/// ...snip...
pcap_dispatch(handle, 100, &callback, NULL);
This resulted in the equally perplexing error:
main.c: In function ‘start_capture’:
main.c:96:27: warning: initialization from incompatible pointer type [enabled by default]
It's the first time I've run across function pointers with special typedef'ed types, the man page for pcap_{loop,dispatch} reads:
NAME
pcap_loop, pcap_dispatch - process packets from a live capture or savefile
SYNOPSIS
#include
typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *h,
const u_char *bytes);
int pcap_loop(pcap_t *p, int cnt,
pcap_handler callback, u_char *user);
int pcap_dispatch(pcap_t *p, int cnt,
pcap_handler callback, u_char *user);
Solved
The function signature should be:
void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet);
I had:
void got_packet(u_char *args, struct pcap_pkthdr *header, const u_char *packet);
I suppose in some ways the error makes sense?! But anyway Solved.