dear
i wrote this code to calculate wind speed from anemometer
below the error message
windspeedcode2:15: error: 'FreqCount' is not a class, namespace, or
enumeration
FreqCount::f_comp= 8; // Set compensation to 12
^
windspeedcode2:16: error: 'FreqCount' is not a class, namespace, or
enumeration
FreqCount::start(100); // Start counting with gatetime of
100ms
^
windspeedcode2:17: error: 'FreqCounter' has not been declared
while (FreqCounter::f_ready == 0) // wait until counter
ready
^
windspeedcode2:19: error: 'FreqCount' is not a class, namespace, or
enumeration
freq=FreqCount::f_freq;//read frequency value
^
exit status 1 'FreqCount' is not a class, namespace, or enumeration
This report would have more information with "Show verbose output
during compilation" option enabled in File -> Preferences.
:: is the scope resolution operator for defining the same function outside the class
. is the dot operator used to call a member function (or member variable) on a object.
An example would be (assuming a instance named FreqCount exist in you library header): FreqCount.f_comp= 8;
Only if f_comp is a static class member variable can it be accessed is you called it: FreqCount::f_comp= 8; But that is unlikely for a library.
So what is in your header and where does the library come from?
thank you for your help the problem has been solved by downloading another library
as shown in picture
Related
I use an object based on a base package roughly defined as:
package Base is
type T_Base is abstract tagged null record;
-- This performs a deep copy. Shallow copies may lead to STORAGE_ERROR.
-- This shall be implemented by every derived type.
function Copy (From : in T_Base) return T_Base'Class is abstract;
end package Base;
This package is derived by several packages which are further derived
package Foo is
type T_Foo is new T_Base with record
A_Data : Natural; -- Of course, in the real code, these are types by far more complex.
end record;
procedure do_something (Foo_Object : in T_Foo);
-- This implements the deep copy
function Copy (From : in T_Foo) return T_Base'Class is abstract;
end package Foo;
On calling the procedure do_something, I do get a storage_error:
procedure handle_received_foo (Foo_In: in Foo.T_Foo) is
begin
Foo.do_something (Foo_Object => Foo_In); -- The storage error does happen here.
end main;
When running the code with gdb, I get a segfault on entering the function and I get:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 39 (LWP 39)]
0x033c9828 in foo.do_something (foo_object=...) at ./foo.adb:67
67 procedure do_something (Foo_Object : in T_Foo);
(gdb) p foo_object
$1 (null)
So I guess I get a storage_error when doing the shallow copy of the argument Foo_Object.
I am aware that this is no MWE and that there might be a mistake in one of the types present used in the derived types.
I can't find any good option:
Making T_Foo a Controlled type to call Copy in Adjust seems not to be possible without greatly changing its definition as I can't derive T_Foo both from T_Base and Ada.Finalization.Controlled since none of them is an interface types
Defining T_Base as
type T_Base is abstract new Ada.Finalization.Controlled with null record;
and override Adjust here seems to induce a hell lot too much modifications on the existing code base as gnat yields in multiple places
type of aggregate has private ancestor "Controlled" must use extension aggregate.
So I'm low on solutions to either investigate the problem further or to solve it with a hammer.
The problem was not in the Copy function. The comments I saw in the code base were misleading.
The fact that introducing new variables changed the location of the exception made me consider some stack overflow problems.
Indeed the Storage_Size allocated for the task was not sufficient. Increasing the pragma Storage_Size(<value>) solved the problem.
Since the code base is compiled with -fstack-check, this led to the aforementioned STORAGE_ERROR.
More infos on Adacore's documentation.
This could probably have been seen with Gem #95: Dynamic Stack Analysis in GNAT but I am not currently able to see any result with the binding option suggested therein.
Since there's nothing about this on google, I opened this issue.
I'm trying to compile this code:
module Random: Mirage_random.S = struct
include Mirage_random_stdlib
end
module Ipv4: Static_ipv4.Make(Random, Clock, Ethernet, Arp) = struct
include Static_ipv4
end
but I get this:
root#66f08fd7c55b:/workspaces/ocaml_env/mirage-tcpip/examples/raw_ip_tcp_example# dune build raw_ip_tcp_example.exe
Entering directory '/workspaces/ocaml_env/mirage-tcpip'
File "examples/raw_ip_tcp_example/raw_ip_tcp_example.ml", line 44, characters 36-37:
44 | module Ipv4: Static_ipv4.Make(Random, Clock, Ethern
^
Error: Syntax error: module path expected.
You can see the static_ipv4 file here https://github.com/mirage/mirage-tcpip/blob/master/src/ipv4/static_ipv4.mli#L17
I don't have any idea of why this error happens. I didn't include Clock, Ethernet, Arp because the error is already on Random. You can see the random signature here: https://github.com/mirage/mirage-random/blob/master/src/mirage_random.ml and the implementation I'm including here https://github.com/mirage/mirage-random-stdlib
I don't know about Mirage at all, but conventionally Make is a functor. I.e., it maps modules to modules. But you have the call in the syntactic position of a module type.
I would expect something more like this:
module Ipv4 = Static_ipv4.Make(. . .)
My apologies if this isn't helpful.
First, you have a syntax error, functor application should be written:
Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp)
Then you have a kind error: Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp) is a module expression, not a module type. Moreover, it is not clear if you even need a signature constraint. Simply writing
module Ipv4 = struct
include Static_ipv4
let more = 0
end
works if you wanted to make an extended version of the Static_ipv4 module.
But maybe, you wanted to add few functions to the functor result?
In this case, you can use:
module Ipv4 = struct
include Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp)
let an_new_and_shiny_function = ()
end
If you really want to enforce that the type is the same, you need to reuse the signature of the functor result:
module Ipv4: sig
include Mirage_protocols.IP with type ipaddr = Ipaddr.V4.t
val connect : ip:(Ipaddr.V4.Prefix.t * Ipaddr.V4.t) -> ?gateway:Ipaddr.V4.t ->
end
= struct
include Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp)
let an_new_and_shiny_function.
end
I have found similar questions but none that worked for my situation, so I am asking my own.
I want to use a library function that takes a pointer to a std::vector, and fills it with data.
I already have a C++/CLI Wrapper set up.
I am currently trying to instantiate the vector in the wrapper,
private:
std::vector<int>* outputVector
and in the constructor, I instantiate it :
outputVector = new std::vector<int>();
Now, in the wrapper method that calls the c++ library function :
m_pUnmanagedTPRTreeClass->GetInRegion(..., &outputVector)
I omitted the other parameters because they dont matter for this case. I can already use other functions of the library and they work without a problem. I just can't manage to pass a pointer to a std::vector.
With the code like this, I get the error message :
error C2664: 'TPSimpleRTree<CT,T>::GetInRegion' : cannot convert parameter 3 from 'cli::interior_ptr<Type>' to 'std::vector<_Ty> &'
I have tried removing the "&", as I am not great at C++ and am unsure how to correctly use pointers. Then, the error becomes :
error C2664: 'TPSimpleRTree<CT,T>::GetInRegion' : cannot convert parameter 3 from 'std::vector<_Ty> *' to 'std::vector<_Ty> &'
EDIT: I have tried replacing "&" by "*", it does not work, I get the error :
cannot convert from 'std::vector<_Ty>' to 'std::vector<_Ty> &'
The signature of the c++ function for the vector is so :
GetInRegion(..., std::vector<T*>& a_objects)
Given the signature:
GetInRegion(..., std::vector<T*>& a_objects)
You would call this (in C++ or C++/CLI) like:
std::vector<int*> v;
m_pUnmanagedTPRTreeClass->GetInRegion(..., v);
Then you can manipulate the data as needed or marshall the data into a .Net container.
'std::vector<_Ty> *' to 'std::vector<_Ty> &'
is self explanatory, you need to dereference instead of taking a pointer, so instead of:
m_pUnmanagedTPRTreeClass->GetInRegion(..., &outputVector)
use:
m_pUnmanagedTPRTreeClass->GetInRegion(..., *outputVector)
^~~~~~~!!
after your edit I see your getinregion signature is:
GetInRegion(..., std::vector<T*>& a_objects)
so it accepts std::vector where T is a pointer, while you want to pass to getinregion a std::vector where int is not a pointer.
I am trying to compile a code using my own compiler (CodeDOM), but on codes like this:
390. sealed class FunctorComparer`1 {
421. public System.Array+FunctorComparer`1[T] () {}
448. abstract public interface IEnumerator`1 {
... (1676 matches) ...
i am getting this error:
c:\Users\[Username]\AppData\Local\Temp\0z4zag32.0.cs(390,29) : error CS1056: Unexpected character '`'
what am I missing?
[EDIT (1, "16:25", "4 May")]
the code i m trying to compile is not written by me. I don't know what that
character stands for, learning it. But i found that on this site
http://submain.com/ghostdoc/samples/PowerCollections/HTML/html/75549028.htm
it is being used, and it is strange the CodeDOM doesnt parse it.
The backticks should be removed from the code. This is what the error code is hinting at.
They were likely added due to an overzealous escaping on the part of the system you're getting this code sample from.
The name of any member (field, property, method, class) can not contain the character
'`'
If you are reading details from
System.Reflection
It will add this character, i m not sure it s need, may be because it is overidding a virtual member x times. like
System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult] //1 time
System.Threading.Tasks.Task`6[System.Threading.Tasks.VoidTaskResult] //6 times
Just taking the first part of the declaration is complete, and contains all the informations the computer needs to do the work.
from
System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult]
to
System.Threading.Tasks.Task
Is there a way to check whether a c library can be found by the system?
I tried to use a try catch block on a library call to test whether it exists, but that actually kills the program.
try
ccall( (:func, "libfoo"), Bool, () )
catch
println("This line is never called. Ever")
end
The associated error is:
ERROR: error compiling anonymous: could not load module libfoo: libfoo: cannot open shared object file: No such file or directory
You could look before you leap using find_library:
julia> find_library(["libc"])
"libc"
julia> find_library(["libfoo"])
""
where you'll get the empty string if not found.
julia> help(find_library)
INFO: Loading help data...
Base.find_library(names, locations)
Searches for the first library in "names" in the paths in the
"locations" list, "DL_LOAD_PATH", or system library paths (in
that order) which can successfully be dlopen'd. On success, the
return value will be one of the names (potentially prefixed by one
of the paths in locations). This string can be assigned to a
"global const" and used as the library name in future
"ccall"'s. On failure, it returns the empty string.