How do you create a map or hashtable with a datatype value? - ats

I feel like I've asked this very question and gotten an answer before, but I'm not able to find that Q&A.
Hashtables and maps as documented in the ATS2 tutorial have undocumented requirements. The big problem is that I can't see figure out those requirements from seeing the errors that result from not providing them.
So for example this string -> datatype map:
#include "share/atspre_staload.hats"
#include "share/atspre_staload_libats_ML.hats"
datatype example = example of (string)
// commented: this doesn't change the error output
//fn fprint_example(out: FILEref, w: example): void = fprint!(out, "(not implemented)")
//overload fprint with fprint_example
local
typedef key = string
and itm = example
staload "libats/ML/SATS/funmap.sats"
in
#include "libats/ML/HATS/myfunmap.hats"
end
val test = myfunmap_nil()
implement main0() = ()
fails to build with these errors:
patscc -DATS_MEMALLOC_GCBDW -o test test.dats -latslib -lgc
test_dats.c:20972:54: warning: implicit declaration of function 'S2Ecst' is invalid in C99 [-Wimplicit-function-declaration]
ATSINSmove(tmp859__1, PMVtmpltcstmat[0](tostrptr_val<S2Ecst(example)>)(arg1)) ;
^
test_dats.c:20972:61: error: use of undeclared identifier 'example'
ATSINSmove(tmp859__1, PMVtmpltcstmat[0](tostrptr_val<S2Ecst(example)>)(arg1)) ;
^
test_dats.c:20972:41: error: use of undeclared identifier 'tostrptr_val'
ATSINSmove(tmp859__1, PMVtmpltcstmat[0](tostrptr_val<S2Ecst(example)>)(arg1)) ;
^
test_dats.c:20972:70: error: expected expression
ATSINSmove(tmp859__1, PMVtmpltcstmat[0](tostrptr_val<S2Ecst(example)>)(arg1)) ;
^
test_dats.c:20972:23: error: use of undeclared identifier 'PMVtmpltcstmat'
ATSINSmove(tmp859__1, PMVtmpltcstmat[0](tostrptr_val<S2Ecst(example)>)(arg1)) ;
^
1 warning and 4 errors generated.
make: *** [test] Error 1
So it seems that a tostrptr_val<example> is unimplemented...
... and at this point, of forming this question, I found prelude/*/tostring where this stuff is implemented. OK. That brought me to
#include "share/atspre_staload.hats"
#include "share/atspre_staload_libats_ML.hats"
datatype example = example of (string)
fn tostrptr_example(ex: example):<!wrt> Strptr1 = $UNSAFE.castvwtp0{Strptr1}("not implemented")
fn tostring_example(ex: example):<> string = "not implemented"
fn fprint_example(out: FILEref, ex: example): void = fprint!(out, tostring_example(ex))
implement tostrptr_val<example> = tostrptr_example
implement tostring_val<example> = tostring_example
implement fprint_val<example> = fprint_example
local
typedef key = string
and itm = example
staload "libats/ML/SATS/funmap.sats"
in
#include "libats/ML/HATS/myfunmap.hats"
end
val test = myfunmap_nil()
implement main0() = ()
which still doesn't compile:
patscc -DATS_MEMALLOC_GCBDW -o test test.dats -latslib -lgc
test_dats.c:20765:31: warning: implicit declaration of function 'fprint_example_5' is invalid in C99 [-Wimplicit-function-declaration]
ATSINSmove_void(tmpret822__1, fprint_example_5(env0, arg1)) ;
^
1 warning generated.
Undefined symbols for architecture x86_64:
"_fprint_example_5", referenced from:
_ATSLIB_056_libats_056_funmap_avltree__funmap_foreach__fwork__123__1 in test_dats-bd83ab.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1
All I can decipher from this is that a single function in /libats/DATS/funmap_avltree.dats is using example in a manner I haven't prepared for.

You need to implement a fprint_val instanace for printing 'example':
implement fprint_val<example>(out, x) = ...

Related

What Else Do I Need to Do to Run the lwIP Simulation in Omnet++?

I am still trying to run the following simulation on Omnet 5.6.1 (using INET 4.2.5) inet/examples/inet/nclients/omnetpp.ini.
When I build INET without TCP (lwIP) checkbox checked in the Project Features window I get a clean build. If I check the checkbox I get the following 26 errors:
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:47:9: error: expected ';' at end of declaration list
u32_t s_addr;
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: error: functions that differ only in their return type cannot be overloaded
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: warning: 'inet_addr' redeclared without 'dllimport' attribute: previous 'dllimport' ignored [-Winconsistent-dllimport]
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:47:9: error: expected ';' at end of declaration list
u32_t s_addr;
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: error: functions that differ only in their return type cannot be overloaded
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: warning: 'inet_addr' redeclared without 'dllimport' attribute: previous 'dllimport' ignored [-Winconsistent-dllimport]
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: error: conflicting types for 'inet_ntoa'
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: warning: 'inet_ntoa' redeclared without 'dllimport' attribute: previous 'dllimport' ignored [-Winconsistent-dllimport]
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:47:9: error: expected ';' at end of declaration list
u32_t s_addr;
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: error: conflicting types for 'inet_ntoa'
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: error: functions that differ only in their return type cannot be overloaded
u32_t inet_addr(const char *cp);
::38: C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winnt.h WINSOCK_API_LINKAGE unsigned __LONG32 WSAAPI inet_addr(const char *cp);:
C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winnt.h:147:37: WINSOCK_API_LINKAGE u_short WSAAPI htons(u_short hostshort);52
^inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h
:111:7: error: functions that differ only in their return type cannot be overloaded
u32_t htonl(u32_t x);
In file included from inet/transportlayer/tcp_lwip/lwip/include\lwip/lwip_tcp.hC:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winnt.hinet/transportlayer/tcp_lwip/lwip/include\lwip/lwip_tcp.h::52: WINSOCK_API_LINKAGE unsigned __LONG32 WSAAPI inet_addr(const char *cp);147:
:In file included from
37 ^inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/lwip_ip.h
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: error: conflicting types for 'inet_ntoa'
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:111:7: error: functions that differ only in their return type cannot be overloaded
u32_t htonl(u32_t x);
In file included from inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/lwip_ip.h::112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
119:9: C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winsock2.hwarning:: 'IN_CLASSB_HOST' macro redefined [-Wmacro-redefined]
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:111:7: error: functions that differ only in their return type cannot be overloaded
u32_t htonl(u32_t x);
In file included from inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/ip_addr.h:37:
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
9 warnings and 5 errors generated.
9 warnings and 5 errors generated.
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/LwipTcpLayer.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/lwip/core/memp.o] Error 1
9 warnings and 5 errors generated.
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/TcpLwipConnection.o] Error 1
9 warnings and 5 errors generated.
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/TcpLwip.o] Error 1
make[1]: Leaving directory '/c/OMNET/omnetpp561/inet4/src'
make: *** [Makefile:7: all] Error 2
"make MODE=debug -j4 all" terminated with exit code 2. Build might be incomplete.
When I try to run the simulation I get the following error:
<!> Error: Cannot load library '../../../src//libINET.dll': The specified module could not be found
End.
Simulation terminated with exit code: 1
Working directory: C:/OMNET/omnetpp561/inet4/examples/inet/nclients
Command line: ../../../../../../Pakhuis/Akademie/MEng/Thesis/Simulasie/WorkSpaces/ThesisSimulations/ThesisSimulations/src/ThesisSimulations.exe -m -n ../../../src;../..;../../../tutorials;../../../showcases --image-path=../../../images -l ../../../src/INET omnetpp.ini
<!> Error: Cannot load library '../../../src//libINET.dll': The specified module could not be found
End.
Simulation terminated with exit code: 1
Working directory: C:/OMNET/omnetpp561/inet4/examples/inet/nclients
Command line: ../../../../../../Pakhuis/Akademie/MEng/Thesis/Simulasie/WorkSpaces/ThesisSimulations/ThesisSimulations/src/ThesisSimulations.exe -m -n ../../../src;../..;../../../tutorials;../../../showcases --image-path=../../../images -l ../../../src/INET omnetpp.ini
Environment variables:
PATH=;C:/OMNET/omnetpp561/inet4/src;C:\OMNET\omnetpp561\omnetpp-5.6.1\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin;;C:/OMNET/omnetpp561/omnetpp-5.6.1/ide/jre/bin/server;C:/OMNET/omnetpp561/omnetpp-5.6.1/ide/jre/bin;C:/OMNET/omnetpp561/omnetpp-5.6.1/ide/jre/lib/amd64;.;C:\OMNET\omnetpp561\omnetpp-5.6.1\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\local\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin\site_perl;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin\vendor_perl;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin\core_perl;C:\OMNET\omnetpp561\omnetpp-5.6.1;
OMNETPP_ROOT=C:/OMNET/omnetpp561/omnetpp-5.6.1/
OMNETPP_IMAGE_PATH=C:\OMNET\omnetpp561\omnetpp-5.6.1\images
I have tried re installing OMNET++ and using other INET versions. I also tried using OMNET 4.2.2 with no success.
Can someone please advise what I should do?
Kind regards
Benjamin
The TCP_LWIP feature works only on Linux. On Windows, certain functions are clashing with the windows winsock2 library. (That's why the feature is disabled by default)

Swoole make failed ubuntu16.04

I am trying to install SWOOLE on my Ubuntu-16.04
I tried this sudo pecl install swoole
But am getting a long list of errors(Skipped some lines)
In file included from /tmp/pear/temp/swoole/php_swoole.h:156:0,
from /tmp/pear/temp/swoole/swoole.c:16:
/tmp/pear/temp/swoole/php7_wrapper.h: In function 'sw_zend_is_callable':
/tmp/pear/temp/swoole/php7_wrapper.h:238:5: error: unknown type name 'zend_string'
zend_string *key = NULL;
^
/tmp/pear/temp/swoole/php7_wrapper.h:239:5: warning: passing argument 3 of 'zend_is_callable' from incompatible pointer type [enabled by default]
int ret = zend_is_callable(cb, a, &key);
^
In file included from /usr/include/php5/main/php.h:39:0,
from /tmp/pear/temp/swoole/php_swoole.h:25,
from /tmp/pear/temp/swoole/swoole.c:16:
/usr/include/php5/Zend/zend_API.h:301:20: note: expected 'char **' but argument is of type 'int **'
ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, char **callable_name TSRMLS_DC);
^
In file included from /usr/include/php5/Zend/zend.h:252:0,
from /usr/include/php5/main/php.h:35,
from /tmp/pear/temp/swoole/php_swoole.h:25,
from /tmp/pear/temp/swoole/swoole.c:16:
/tmp/pear/temp/swoole/php7_wrapper.h:240:29: error: request for member 'val' in something not a structure or union
char *tmp = estrndup(key->val, key->len);
^
/usr/include/php5/Zend/zend_alloc.h:78:44: note: in definition of macro 'estrndup'
#define estrndup(s, length) _estrndup((s), (length) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
^
/tmp/pear/temp/swoole/php7_wrapper.h:240:39: error: request for member 'len' in something not a structure or union
char *tmp = estrndup(key->val, key->len);
^
/usr/include/php5/Zend/zend_alloc.h:78:49: note: in definition of macro 'estrndup'
#define estrndup(s, length) _estrndup((s), (length) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
^
In file included from /tmp/pear/temp/swoole/php_swoole.h:156:0,
from /tmp/pear/temp/swoole/swoole.c:16:
/tmp/pear/temp/swoole/php7_wrapper.h: In function 'sw_zend_is_callable_ex':
/tmp/pear/temp/swoole/php7_wrapper.h:248:5: error: unknown type name 'zend_string'
zend_string *key = NULL;
^
/tmp/pear/temp/swoole/php7_wrapper.h:249:5: warning: passing argument 4 of 'zend_is_callable_ex' from incompatible pointer type [enabled by default]
int ret = zend_is_callable_ex(callable, NULL, check_flags, &key, fcc, error);
make: *** [swoole.lo] Error 1
ERROR: `make' failed
I have also tried this
cd swoole-src
./configure
make
Which is also giving the similar errors.
How to solve this? thanks in advance!
EDIT : Added the first Generated ERRORS too

Why does this template work in a single file but not across files?

Consider array.sats:
#include "share/atspre_staload.hats"
fun {a:t#ype} make: (int, a) -> void
array.dats:
#include "share/atspre_staload.hats"
staload "./array.sats"
implement {a} make(n: int, x: a) = ()
and example.dats:
staload Array = "./array.sats"
implement main0() = () where {
val arr = $Array.make<int>(10, 42)
}
These fail to compile with a bunch of template errors:
$ make clean all
rm -fv *_[sd]ats.[co] example
removed 'array_dats.c'
removed 'array_dats.o'
removed 'array_sats.c'
removed 'array_sats.o'
removed 'example_dats.c'
patscc -DATS_MEMALLOC_GCBDW -c array.sats
clang: warning: argument unused during compilation: '-L/usr/local/lib/ats2-postiats-0.3.9/ccomp/atslib/lib' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/local/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64' [-Wunused-command-line-argument]
patscc -DATS_MEMALLOC_GCBDW -c array.dats
clang: warning: argument unused during compilation: '-L/usr/local/lib/ats2-postiats-0.3.9/ccomp/atslib/lib' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/local/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64' [-Wunused-command-line-argument]
patscc -DATS_MEMALLOC_GCBDW -o example example.dats -lgc
example_dats.c:169:23: error: use of undeclared identifier 'PMVtmpltcstmat'
ATSINSmove_void(tmp1, PMVtmpltcstmat[0](make<S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))>)(ATSPMVi0nt(10), ATSPMVi0nt(42))) ;
^
example_dats.c:169:46: warning: implicit declaration of function 'S2Eapp' is invalid in C99 [-Wimplicit-function-declaration]
ATSINSmove_void(tmp1, PMVtmpltcstmat[0](make<S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))>)(ATSPMVi0nt(10), ATSPMVi0nt(42))) ;
^
example_dats.c:169:53: warning: implicit declaration of function 'S2Ecst' is invalid in C99 [-Wimplicit-function-declaration]
ATSINSmove_void(tmp1, PMVtmpltcstmat[0](make<S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))>)(ATSPMVi0nt(10), ATSPMVi0nt(42))) ;
^
example_dats.c:169:60: error: use of undeclared identifier 'g0int_t0ype'
ATSINSmove_void(tmp1, PMVtmpltcstmat[0](make<S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))>)(ATSPMVi0nt(10), ATSPMVi0nt(42))) ;
^
example_dats.c:169:41: error: use of undeclared identifier 'make'
ATSINSmove_void(tmp1, PMVtmpltcstmat[0](make<S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))>)(ATSPMVi0nt(10), ATSPMVi0nt(42))) ;
^
example_dats.c:169:99: error: expected expression
ATSINSmove_void(tmp1, PMVtmpltcstmat[0](make<S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))>)(ATSPMVi0nt(10), ATSPMVi0nt(42))) ;
^
2 warnings and 4 errors generated.
make: *** [example] Error 1
Meanwhile the same content in a single file compiles and runs without error:
#include "share/atspre_staload.hats"
extern fun {a:t#ype} make: (int, a) -> void
#include "share/atspre_staload.hats"
implement {a} make(n: int, x: a) = ()
implement main0() = () where {
val arr = make<int>(10, 42)
}
What's wrong with the separated code? Very similar code in the $UNSAFE files seems to work fine with templates and with a namespace.
You also need to staload array.dats:
staload Array = "./array.sats"
staload _(*Array*) = "./array.dats"
implement main0() = () where {
val arr = $Array.make<int>(10, 42)
}

EGlib 2.6.20 does not install (trying to install SCIP)

I am trying to solve an integer linear program using SCIP. The beta version that I require (for exact solving) is given at:
http://scip.zib.de/#exact
As linked there, the source code is at:
http://scip.zib.de/download.php?fname=scip-3.0.0-ex.tgz
I followed the INSTALL file. It requires the installation of EGlib 2.6.20. However, this installation fails during 'make' with the following error:
phani#OptiPlex-9030-AIO ~/EGlib-2.6.20 $ make
make[1]: Entering directory '/home/phani/EGlib-2.6.20'
make[1]: Leaving directory '/home/phani/EGlib-2.6.20'
make[1]: Entering directory '/home/phani/EGlib-2.6.20'
Building include/EGlib.h
Compiling src/eg_bit.c
Compiling src/eg_compare.c
Compiling src/eg_io.c
src/eg_io.c: In function ‘EGioGets’:
src/eg_io.c:618:7: warning: unused variable ‘b’ [-Wunused-variable]
char*b = buf;
^
src/eg_io.c: In function ‘EGioEof’:
src/eg_io.c:648:6: warning: unused variable ‘err’ [-Wunused-variable]
int err;
^
src/eg_io.c: In function ‘EGmvar’:
src/eg_io.c:42:2: warning: second parameter of ‘va_start’ not last named argument [-Wvarargs]
va_start (largs, nind);
^
Compiling src/eg_lpnum.c
Compiling src/eg_net.c
Compiling src/eg_random.c
Compiling src/eg_macros.c
Compiling src/eg_ehash.c
Compiling src/eg_perm_it.c
Compiling src/eg_symtab.c
Compiling src/eg_keytab.c
Compiling src/eg_simula.c
In file included from src/eg_simula.c:25:0:
src/eg_simula.h:227:2: error: unknown type name ‘dbl_EGeHeapCn_t’
dbl_EGeHeapCn_t heap_cn;/**< connector in the heap containing the agent */
^
src/eg_simula.h:240:2: error: unknown type name ‘dbl_EGeHeap_t’
dbl_EGeHeap_t hp; /**< Heap containing events to be processed */
^
src/eg_simula.c: In function ‘EGsimExp’:
src/eg_simula.c:29:30: warning: unused parameter ‘t’ [-Wunused-parameter]
double EGsimExp(const double t, void*const data)
^
src/eg_simula.c: In function ‘EGsimUniform’:
src/eg_simula.c:40:34: warning: unused parameter ‘t’ [-Wunused-parameter]
double EGsimUniform(const double t, void*const data)
^
src/eg_simula.c: In function ‘EGsimNormal’:
src/eg_simula.c:51:33: warning: unused parameter ‘t’ [-Wunused-parameter]
double EGsimNormal(const double t, void*const data)
^
In file included from src/eg_simula.c:25:0:
src/eg_simula.c: In function ‘EGsimNewEvent’:
src/eg_simula.h:277:2: warning: implicit declaration of function ‘dbl_EGeHeapCnInit’ [-Wimplicit-function-declaration]
dbl_EGeHeapCnInit(&(__EGsimA->heap_cn));\
^
src/eg_simula.c:73:2: note: in expansion of macro ‘EGsimSetAgent’
EGsimSetAgent(la,sim->cur_time + gen->gen(sim->cur_time,gen->data));
^
src/eg_simula.c:74:13: error: request for member ‘val’ in something not a structure or union
la->heap_cn.val = la->last_time;
^
src/eg_simula.c:77:12: error: request for member ‘sz’ in something not a structure or union
if(sim->hp.sz == sim->hp.max_sz)
^
src/eg_simula.c:77:26: error: request for member ‘max_sz’ in something not a structure or union
if(sim->hp.sz == sim->hp.max_sz)
^
src/eg_simula.c:78:3: warning: implicit declaration of function ‘dbl_EGeHeapResize’ [-Wimplicit-function-declaration]
dbl_EGeHeapResize(&(sim->hp),sim->hp.sz*2);
^
src/eg_simula.c:78:39: error: request for member ‘sz’ in something not a structure or union
dbl_EGeHeapResize(&(sim->hp),sim->hp.sz*2);
^
src/eg_simula.c:80:9: warning: implicit declaration of function ‘dbl_EGeHeapAdd’ [-Wimplicit-function-declaration]
rval = dbl_EGeHeapAdd(&(sim->hp),&(la->heap_cn));
^
In file included from src/eg_simula.h:47:0,
from src/eg_simula.c:25:
src/eg_simula.c:85:55: error: request for member ‘val’ in something not a structure or union
MESSAGE(EG_SIM_VERBOSE,"new Agent at %lf",la->heap_cn.val);
^
src/eg_macros.h:246:18: note: in definition of macro ‘MESSAGE’
fprintf(stderr,__VA_ARGS__);\
^
In file included from src/eg_simula.h:47:0,
from src/eg_simula.c:25:
src/eg_simula.c: In function ‘EGsim’:
src/eg_simula.c:284:22: warning: implicit declaration of function ‘dbl_EGeHeapGetMin’ [-Wimplicit-function-declaration]
ca = EGcontainerOf(dbl_EGeHeapGetMin(&(sim->hp)), EGsimAgent_t,heap_cn);
^
src/eg_macros.h:134:56: note: in definition of macro ‘EGcontainerOf’
typeof(((__type *)0)->__member) *const __EGcOf_ptr = (__ptr);\
^
src/eg_macros.h:134:55: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
typeof(((__type *)0)->__member) *const __EGcOf_ptr = (__ptr);\
^
src/eg_simula.c:284:8: note: in expansion of macro ‘EGcontainerOf’
ca = EGcontainerOf(dbl_EGeHeapGetMin(&(sim->hp)), EGsimAgent_t,heap_cn);
^
src/eg_simula.c:285:30: error: request for member ‘val’ in something not a structure or union
sim->cur_time = ca->heap_cn.val;
^
src/eg_simula.c:327:17: error: request for member ‘val’ in something not a structure or union
na->heap_cn.val = sim->cur_time + cn->gen(sim->cur_time,cn->data);
^
src/eg_simula.c:328:6: warning: implicit declaration of function ‘dbl_EGeHeapSiftUp’ [-Wimplicit-function-declaration]
dbl_EGeHeapSiftUp(&(sim->hp),&(na->heap_cn));
^
src/eg_simula.c:365:17: error: request for member ‘val’ in something not a structure or union
ca->heap_cn.val = sim->cur_time;
^
src/eg_simula.c:371:17: error: request for member ‘val’ in something not a structure or union
ca->heap_cn.val = sim->cur_time + nn->gen(sim->cur_time,nn->data);
^
src/eg_simula.c:377:17: error: request for member ‘val’ in something not a structure or union
ca->heap_cn.val = DBL_MAX;
^
src/eg_simula.c:381:12: warning: implicit declaration of function ‘dbl_EGeHeapSiftDown’ [-Wimplicit-function-declaration]
rval = dbl_EGeHeapSiftDown(&(sim->hp),&(ca->heap_cn));
^
src/eg_simula.c:388:5: warning: implicit declaration of function ‘dbl_EGeHeapDel’ [-Wimplicit-function-declaration]
dbl_EGeHeapDel(&(sim->hp),&(ca->heap_cn));
^
src/eg_simula.c:429:17: error: request for member ‘val’ in something not a structure or union
ca->heap_cn.val = sim->cur_time;
^
src/eg_simula.c:433:17: error: request for member ‘val’ in something not a structure or union
ca->heap_cn.val = sim->cur_time + nn->gen(sim->cur_time,nn->data);
^
src/eg_simula.c:441:17: error: request for member ‘val’ in something not a structure or union
ca->heap_cn.val = DBL_MAX;
^
Makefile.library:38: recipe for target 'obj/eg_simula.o' failed
make[1]: *** [obj/eg_simula.o] Error 1
make[1]: Leaving directory '/home/phani/EGlib-2.6.20'
Makefile:23: recipe for target 'library' failed
make: *** [library] Error 2
After some searching, I have noticed that dbl_EGeHeap_t is not defined in the source code, and that seems to be throwing errors.
On searching online, it seems to be the case that it was defined in EGlib 2.6.15 (https://conexo.dii.uchile.cl/SVN/EGlib/EGlib2/tags/EGlib-2.6.15/TEmplate/dbl_eg_eheap.h), but the corresponding file in 2.6.20 does not have the definition.
Has anybody else experienced this? I badly need a solution to this.

Compile error when using ffmpeg

I've found a strange problem during the compile of an example of ffmpeg in Qt Mac.
I have installed the ffmpeg library and I have tested the examples of this with cc and gcc compiler on the terminal, and I don't have any problem in the case of compile and run.
But when I call the library (ffmpeg are C library) in Qt for compile the same code of the example, the g++ compiler give me many error.
I have used this structure in the main.cpp code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
extern "C" {
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
}
#include <QDebug>
and the Compile Output gives me:
In file included from ../audvid/main.cpp:7:
/opt/local/include/libavutil/timestamp.h: In function 'char*
av_ts_make_string(char*, int64_t)':
/opt/local/include/libavutil/timestamp.h:48: warning: comparison
between signed and unsigned integer expressions
/opt/local/include/libavutil/timestamp.h:49: error: expected `)'
before 'PRId64' /opt/local/include/libavutil/timestamp.h:49: warning:
spurious trailing '%' in format
/opt/local/include/libavutil/timestamp.h:49: warning: too many
arguments for format /opt/local/include/libavutil/timestamp.h: At
global scope: /opt/local/include/libavutil/timestamp.h:68: error:
'AVRational' has not been declared
/opt/local/include/libavutil/timestamp.h: In function 'char*
av_ts_make_time_string(char*, int64_t, int*)':
/opt/local/include/libavutil/timestamp.h:70: warning: comparison
between signed and unsigned integer expressions
/opt/local/include/libavutil/timestamp.h:71: error: 'av_q2d' was not
declared in this scope ../audvid/main.cpp: In function 'int
decode_packet(int*, int)': ../audvid/main.cpp:50: error: cannot
convert 'AVRational*' to 'int*' for argument '3' to 'char*
av_ts_make_time_string(char*, int64_t, int*)' ../audvid/main.cpp:73:
error: cannot convert 'AVRational*' to 'int*' for argument '3' to
'char* av_ts_make_time_string(char*, int64_t, int*)'
../audvid/main.cpp:75: error: 'struct AVFrame' has no member named
'channels' ../audvid/main.cpp:84: error: 'struct AVFrame' has no
member named 'channels' ../audvid/main.cpp:90: error: 'struct AVFrame'
has no member named 'channels' ../audvid/main.cpp: In function 'int
open_codec_context(int*, AVFormatContext*, AVMediaType)':
../audvid/main.cpp:112: error: 'av_get_media_type_string' was not
declared in this scope ../audvid/main.cpp:123: error:
'av_get_media_type_string' was not declared in this scope
../audvid/main.cpp:129: error: 'av_get_media_type_string' was not
declared in this scope ../audvid/main.cpp: In function 'int
get_format_from_sample_fmt(const char**, AVSampleFormat)':
../audvid/main.cpp:152: warning: comparison between signed and
unsigned integer expressions ../audvid/main.cpp: In function 'int
main(int, char**)': ../audvid/main.cpp:239: error: invalid conversion
from 'void*' to 'uint8_t**' make: *** [main.o] Error 1 make: Leaving
directory
`/Users/polin/Desktop/audvid/audvid-build- Qt_4_8_0_qt_everywhere_opensource_src_4_8_0_tp-Release'
10:44:37: The process "/usr/bin/make" exited with code 2. Error while
building/deploying project audvid (target: Qt 4.8.0
(qt-everywhere-opensource-src-4.8.0-tp)) When executing step 'Make'
I don't understand if I make a mistake in the code or if I must change the Qt compiler? (and I don't know how can do this)
You need to include libavutil/avutil.h before #include <libavutil/imgutils.h>. Also you need to add #include <libavcodec/avcodec.h>
Because ffmpeg is written in pure C. Some C99 design is incompatible with g++ compiler. So one way to solve it is to find where the "wrong" source codes are and replace them with C++ design style.
e.g.
av_get_bytes_per_sample( static_cast<AVSampleFormat>(format) )
#undef av_err2str
#define av_err2str(errnum) \
av_make_error_string((char*)__builtin_alloca(AV_ERROR_MAX_STRING_SIZE), AV_ERROR_MAX_STRING_SIZE, errnum)
#undef av_ts2timestr
#define av_ts2timestr(ts, tb) \
av_ts_make_time_string((char*)__builtin_alloca(AV_TS_MAX_STRING_SIZE), ts, tb)

Resources