I have written a very very simple program in Visual C++ 2008 SP1.
It just adds up two numbers.
The DLLTest.cpp is:
#include "DllTest.h"
__declspec(dllexport) double Add(double a, double b)
{
return( a + b );
}
And DllTest.h is:
#ifndef _DLL_TEST_H_
#define _DLL_TEST_H_
#endif
__declspec(dllexport) double Add( double, double);
I build the DLL using Visual C++ 2008. When I try to load the library using loadlibrary, I get the following error:
??? Error using ==> loadlibrary at 422 Building DllTest_thunk_pcwin64 failed. Compiler output is:
DllTest_thunk_pcwin64.c C:\Users\Admin\Desktop\DllTest.h(5) : error
C2054: expected '(' to follow 'EXPORTED_FUNCTION'
C:\Users\Admin\Desktop\DllTest.h(5) : error C2085: 'Add' : not in
formal parameter list DllTest_thunk_pcwin64.c(40) : error C2085:
'int8' : not in formal parameter list DllTest_thunk_pcwin64.c(41) :
error C2085: 'uint8' : not in formal parameter list
DllTest_thunk_pcwin64.c(42) : error C2085: 'int16' : not in formal
parameter list DllTest_thunk_pcwin64.c(43) : error C2085: 'uint16' :
not in formal parameter list DllTest_thunk_pcwin64.c(44) : error
C2085: 'int32' : not in formal parameter list
DllTest_thunk_pcwin64.c(45) : error C2085: 'uint32' : not in formal
parameter list DllTest_thunk_pcwin64.c(46) : error C2085: 'int64' :
not in formal parameter list DllTest_thunk_pcwin64.c(47) : error
C2085: 'uint64' : not in formal parameter list
DllTest_thunk_pcwin64.c(48) : error C2085: 'voidPtr' : not in formal
parameter list DllTest_thunk_pcwin64.c(49) : error C2085: 'string' :
not in formal parameter list DllTest_thunk_pcwin64.c(51) : error
C2082: redefinition of formal parameter 'EXPORTED_FUNCTION'
DllTest_thunk_pcwin64.c(51) : error C2143: syntax error : missing ';'
before 'type' DllTest_thunk_pcwin64.c(52) : error C2085:
'EXPORTED_FUNCTIONdoubledoubledoubleThunk' : not in formal parameter
list DllTest_thunk_pcwin64.c(52) : error C2143: syntax error : missing
';' before '{'
I want just to load a simple program, written in Visual C++, in MATLAB. How can I fix this problem?
Thanks for considering my question.
I found the problem. Actually, there were two problems:
1) The MATLAB is 64 bit but I made 32-bit DLL and I had to change the settings in Visual Studio to make 64-bit DLL.
2) It seems the compiler that MATLAB uses for loading the DLL, has problem with 'extern "C"' command. So, I changed the header like this:
#ifndef DllTest_h
#define DllTest_h
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) double Add( double, double);
#ifdef __cplusplus
}
#endif
#endif
And Finally it worked.
Related
I am attempting to build a framework that I just ported some code from Objective C to Swift in, and I'm getting this error:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "LibcOverlayShims.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/swift/shims/LibcOverlayShims.h:80:15: error: declaration of 'sem_t' must be imported from module 'Darwin.sys.semaphore' before it is required
static inline sem_t *_stdlib_sem_open2(const char *name, int oflag) {
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/semaphore.h:43:13: note: declaration here is not visible
typedef int sem_t;
^
<unknown>:0: error: could not build Objective-C module 'SwiftOverlayShims'
The error is happening because of this one file:
https://github.com/losnoco/Cog/blob/swiftingly/Audio/Visualization/VisualizationController.swift
What am I doing wrong?
How to eager load related data in F# using Include method I tried this one:
_ctx.Reports.Include(x => x.Category)
and getting the following error:
Severity Code Description Project File Line Suppression State
Error FS0041 A unique overload for method 'Include' could not be determined based on type information prior to this program point. A type annotation may be needed.
Known type of argument: ^_arg3
Candidates:
- (extension) Linq.IQueryable.Include<'TEntity when 'TEntity : not struct>(navigationPropertyPath: string) : Linq.IQueryable<'TEntity>
- (extension) Linq.IQueryable.Include<'TEntity,'TProperty when 'TEntity : not struct>(navigationPropertyPath: Linq.Expressions.Expression>) : Query.IIncludableQueryable<'TEntity,'TProperty> SharpNews.Application E:\0DevelopingLearn\BackEnd\ASP.NET Core\SharpNews\SharpNews.Application\Admin\Report\GetReports.fs 44 Active
and also two errors are saying x is undefined
Am I using an incorrect syntax?
Casting to seq or IEnumerable<_> will do the trick
context.Users
.Include(fun u -> u.Roles :> seq<Role>)
open System.Collections.Generic
context.Users
.Include(fun u -> u.Roles :> IEnumerable<Role>)
.ThenInclude(fun r -> r.Permissions)
I'm doing VDM++ on VDM++ toolbox lite and below is my example code:
class Course
types
public study :: numsubj : nat1
sem : nat1;
public subjpersem = nat1;
operations
public getsubj:nat1 * nat1 ==>study
getsubj(numsubj,sem) == (
subjpersem := numsubj/sem;
);
end Course
I tried to run the code. Succeeded creating the object but when I run print getsubj(10,2), it returns error Run-Time Error 120: Unknown state component
Can somebody help me thank you in advance
In Overture/VDMJ, this spec gives two type checking errors. Do these not appear in VDMTools?
Error 3247: Symbol 'subjpersem' is not an updatable variable in 'Course' (test.vpp) at line 9:5
Error 3027: Operation returns unexpected type in 'Course' (test.vpp) at line 7:8
Actual: ()
Expected: study
Type checked 1 class in 0.119 secs. Found 2 type errors
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>
Short version
To prevent the compiler from raising a warning about unused variables I define the macro UNUSED as:
UNUSED(x)=x __attribute__((__unused__))
This macro is then employed in some functions' prototypes, for instance :
void ext(int foo, int UNUSED( bar ) )
However, doxygen is unhappy about that and returns some warnings:
/tmp/sandbox/main.cpp:13: warning: argument 'bar' of command #param is not found in the argument list of Dummy::ext(int foo, intUNUSEDbar)
/tmp/sandbox/main.cpp:13: warning: The following parameters of Dummy::ext(int foo, intUNUSEDbar) are not documented:
parameter 'UNUSED'
How should I tell doxygen to ignore the UNUSED macro ?
Long version
I have a code that looks like the following :
#include <iostream>
class Dummy
//! Dummy class
{
public :
//!Dummy function
/**
* \param foo First variable
* \param bar Second variable
*/
void ext(int foo, int UNUSED( bar ) )
{
std::cout << "foo = " << foo << std::endl;
}
};
//!Main function
int main(void)
{
Dummy MyDummy;
MyDummy.ext(1, 2);
return 0;
}
I compile it by invoking :
g++ -D 'UNUSED(x)=x __attribute__((__unused__))' main.cpp
To generate the default doxygen configuration file named Doxyfile I enter :
doxygen -g
Eventually, to generate the documentation I enter :
doxygen Doxyfile
The latter command outputs the following warning :
/tmp/sandbox/main.cpp:13: warning: argument 'bar' of command #param is not found in the argument list of Dummy::ext(int foo, intUNUSEDbar)
/tmp/sandbox/main.cpp:13: warning: The following parameters of Dummy::ext(int foo, intUNUSEDbar) are not documented:
parameter 'UNUSED'
Following instructions from the doxygen documentation, modify the Doxyfile so that it has the following parameters :
#Doxygen will run its own preprocessor before parsing the file
ENABLE_PREPROCESSING = YES
#The Doxygen preprocessor will not only define the macros (default
#behaviour) but also expand them
MACRO_EXPANSION = YES
#The Doxygen preprocessor will only expand the macros that are listed in
#the PREDEFINED setting. Any other macro will merely be defined, and not
#expanded.
EXPAND_ONLY_PREDEF = YES
#The Doxygen preprocessor will replace any occurrence of the UNUSED
#macro by its argument
PREDEFINED = UNUSED(x)=x
After those changes, invoking doxygen Doxyfile no longer raises warnings.