S-function builder not giving output) - anonymous-function

I'm totally new to programming and sfunctions builder (simulink).
Pardon me if I'm not providing correct/required/relevant info.
I had compile my C code from lustre language for a PID
controller. I'm supposed to implement the PID controller C code
into sfunction builder in simulink. I compile the sfunction
builder and it compiles successfully but its not giving an output at
all.
What is going wrong? What more information can I provide to help you solve the problem.

Related

Contracts do not compile with zksync-solc. Their ABI and bytecode seem to be printed as an error

I am pretty new to development and asking questions on stackoverflow, so if there is something else I could provide, please tell me in comments!
I have installed docker, #matterlabs/hardhat-zksync-solc, #matterlabs/hardhat-zksync-deploy, zksync-web3, hardhat, #openzeppelin/contracts-upgradeable, #openzeppelin/contracts and everything else.
A simple contract that stores uint and deploys ERC20 contract compiles fine, but the project I am working on does not compile and instead prints a very long error that seem to be ABIs and bytecodes of every contract that is used in the project.
Here is the beginning of the error:
Error in plugin #matterlabs/hardhat-zksync-solc: {"contracts":{"#openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol":{"ERC1967Proxy":{"abi":[{"inputs":[{"internalType":"address","name":"_logic","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"payable","type":"receive"}],"evm":{"legacyAssembly":null,"bytecode":{"object":"0c0000040004000000010000000000000000ffffffffffffffff0000000000000c000004000400000000ffffffffffffffffffffffffffffffff0000000000000e000000000200000001000000000000000000000000000000000000000000001a020004000800000002000000000000000000000000000000000000000000000c000010001000000001000000000000000001000000000000000000000000000c00001000100
Do you know at what point the code stops, like the specific line/method/function that is causing the contract to fail at compile?
Another option would be to join their discord and drop in on the dev chat here. They've been incredibly helpful and are patient with new devs.

Consuming native C++ (compiled with /CLR) in C#: why does it pretend to work?

I have a body of 'normal' C++ code which I'm trying to make usable by a C# client. I have successfully compiled this with /CLR. I now know that this isn't enough: I have to introduce managed wrapper classes ("ref") to make the code callable from managed code. This question is about what happened before I introduced the ref classes.
I found that the native C++ classes were visible from the C# project, and that I could write
MyNativeClass mnc = new MyNativeClass();
... although any attempt to call a method on the instance was rejected by the compiler. I found that when I ran the C# code, the MyNativeClass constructor was never called - indeed the attempt to instantiate mnc seemed to produce no code at all, so completed without error.
How was C# interpreting the native types in my project? Why did the compiler apparently allow me to instantiate an instance? Why were methods treated differently to the types themselves?
You made two mistakes to make this code work. First is that you declared the C++ class public, like this:
public class MyNativeClass {};
This is not syntax that makes sense in C++ but it is allowed by the C++/CLI compiler. Omitting public would have produced an error message in your C# code, CS0122: "Foo is inaccessible due to its protection level".
Second mistake is that you compiled your native C++ class with /clr in effect. Which works fine, any C++03 compliant code can be compiled to IL and gets just-in-time compiled to machine code by the jitter, just like managed code. And executes fine as well. It is however not efficient to do so, you lost the advantage of having the compile-time optimizer available to produce the best possible code. It still gets optimized, but now by the jitter which doesn't have the same luxury of time available to do as good a job as the C++ code optimizer can do. You avoid this by moving the C++ code in a separate source code file so you can compile it without /clr in effect. Or by using #pragma managed in your source code.
Anyhoo, what you ended up with was an assembly that indeed contains a declaration for MyNativeClass that any managed compiler can see. Something you can see for yourself by running ildasm.exe on the assembly. You'll see that it gets embedded as a value type type. Just a blob of bytes with no constructor and no methods. Which is a decent match for a C++ object from a managed point of view, just bytes that can be stored anywhere a value type can be stored. Declaring a variable of that type in C# works but doesn't do anything useful, it just creates the blob with all bytes set to 0. The only possible use of this declaration is that you can declare a typed pointer to the class and pass it around, that's all.

Linking JavaVM Framework to Xcode - objective C

O.K. I am new to xcode/objective c and have an issue, I have read all the previous comments about linking a framework to and IOS app but it just wont work for me. There must be some dumb mistake I am making so here is what I have done.
Created a new app just to test the JVM-JNI
Linked the JavaVM.framework via the drag and drop method, result was could not access the .h files.
Linked the JavaVM.framework via the Build Phases - Link Binaries With Libraries Method, gives the exact same result.
Is there a tutorial out there somewhere that takes us newbies through the steps (not just refer to read it up somewhere) any help would be appreciated.

How to link with static libraries when building an R package

I'm creating a package that is going to be used by R (the statistical program), I'm not an expert using this application but I have managed to create a very simple package, using the following logic, I have some classes in C++, as the code has to be compiled using the R compiler and it only allows C code, I have a wrapper C code that call the C++ methods, and later I have an R script that call the methods exposed by the C code, so basically is a communication like R <-> C<->C++.
The full tutorial that I used to create this package is found here, I add it as a reference.
Now my problem is that I need to add some functionality to the package that I already created, what I need to do is to add code for late binding to a COM object which is another product that I created and that is registered using regasm tool.
This is the c++ code that I'm using to try to late bind to the COM object, I'm trying to use IDispatch to do so:
{
...
CLSID clsid;
HRESULT hr = CLSIDFromProgID((WCHAR*)"My Com object ProgId", &clsid);
if(FAILED(hr))
return;
...
}
I didn't paste the whole code because only with these lines the compiler is giving me troubles already, the command I use to compile is
R CMD SHLIB Cclass.cc C++class.cc
Where "Cclass.cc" has the C code that call the c++ methods and "C++class.cc" is actually the C++ code.
When I compile these classes the compiler says "undefined reference to `CLSIDFromProgID#8'collect2: ld returned 1 exit status"
I"m sure I have added all the header files that I need, that's why I believe my problem is that I'm not including ole32.lib and oleaut32.lib which are static libraries.
So, my question is, how can I include this libraries in order to be able to use the methods for late binding, like CLSIDFromProgID(...) or QueryInterface(...). Also if anyone believes that my problem is not linking this libraries, but something else, it would be great if can point me to which my problem may be.
Also have in mind that I need to link with those statics libraries in a way that they can be compiled without problem by the R compiler, which if I'm not wrong is a merely c compiler.
I've not tried doing this with C/C++ but rather with Fortran. I had a similar problem in that some standard IO libraries weren't being included in the library I was created. In the end I just included them all and compiled using the Fortran compiler. I didn't use any of the R compiler utilities, just compiled as if I were compiling a static Fortran library normally for use with anything else. This worked fine.
A debug path might be to compile as a static library using gcc (or whatever you're using) then try to include and call that static library from another C program, then if that works try with R.
Hope this is helpful, writing these R packages is pretty hard unless you're using vanilla C or Fortran as far as I can tell.

Tool purely for Syntax Checking?

We have a proprietry system that we develop scripting code in.
We currently do not have a developer environment (apart from Notepad++) and cannot debug or compile this code. We have to submit it to the vendor to insert the code into the test or live system.
The language is essentially C like and has the same syntax.
Basically we want a tool to be able to simply check the syntax of chunks of code we send to the vendor.
Does a tool exist that will do this for me?
You write code in a proprietary scripting language, so you require syntax checking because you cannot compile or debug the code onsite? I'd suggest getting a copy of the language reference (including the BNF if possible) from your vendor, get a compiler-compiler like Coco/R (http://www.ssw.uni-linz.ac.at/coco/), and build yourself a quick and dirty compiler that just validates the abstract syntax tree.
That is to say, yes, there are tools you can use, though perhaps they involve more work than what you may have hoped.
If it's really the same syntax as C you can use a C compiler. Usually there's a syntax check only option (/Zs for MSVC).
I'm not sure how many problems you'll run into since C compilers are pretty picky, and being "like C" is not the same as being C.
It does seem odd that you're being asked to develop code without having any capability to run or even compile it. Kind of like writing a book without being able to proof read it before publishing. I have a hard time getting even "Hello World" programs to compile & run without some sort of goof-up on the very first go.

Resources