powered by simpleCommunicator - 2.0.51     © 2025 Programmizd 02
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / MVS2010 + PB12 - argument type differs from required argument type
7 сообщений из 7, страница 1 из 1
MVS2010 + PB12 - argument type differs from required argument type
    #37525121
bor__bor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Добрый день!

Пробую вызвать внешнюю функцию из dll, откомпилированную в проекте C++ в MVS2010.

Объявляю такие функции в MVS2010

CplusPB.h
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
// CplusPB.h
//#pragma once

//using namespace System;

namespace CplusPB {

	extern "C" __declspec(dllexport) int __stdcall _test1();

	extern "C" __declspec(dllexport) int __stdcall _test2( int a);

	extern "C" __declspec(dllexport) int __stdcall _test3( char* b);
}



CplusPB.cpp
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
#include "stdafx.h"
#include "CplusPB.h"

using namespace CplusPB;

int _test1()
{
	return  200 ;

}


int _test2( int a )
{
	return  1 ;

}


int _test3( char* b )
{
	return  1 ;

}


CplusPB.def
Код: plaintext
1.
2.
3.
4.
5.
LIBRARY CplusPB.dll
EXPORTS test1 = _test1
EXPORTS test2 = _test2
EXPORTS test3 = _test3


Затем на uo объявляю Local External Function

Код: plaintext
1.
2.
3.
4.
 Function  Long test1( ) Library "CplusPB.DLL" ALIAS  FOR  "test1;Ansi"
 Function  Long test2( int a ) Library "CplusPB.DLL" ALIAS  FOR  "test2;Ansi"
 Function  Long test3( ref string b ) Library "CplusPB.DLL" ALIAS  FOR  "test3;Ansi"


и вызов этих функций

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
Long li_ret
int	arg
string	ls_arg


li_ret = test1()
//li_ret = test2(arg)
li_ret = test3(ls_arg)


Функция без аргументов test1() проходит без ошибок, а при добавлении аргументов выскакивает ошибка

---------------------------
PowerBuilder application execution error (R0042)
---------------------------
Application terminated.

Error: Specified argument type differs from required argument type at runtime in DLL function test3.
(invalid stack pointer on return from function call) at line 8 in function uf_add of object uo_cpluspb.
---------------------------
OK
---------------------------


Пробовал разные варианты типа аргумента при объявлении функции в PB12 (вместо Long - int, uint)

Если кто-то с этим сталкивался - как это можно победить?
...
Рейтинг: 0 / 0
MVS2010 + PB12 - argument type differs from required argument type
    #37525309
_Drive_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Добрый день,

если описали ref string ...
Function Long test3( ref string b ) Library "CplusPB.DLL" ALIAS FOR "test3;Ansi"

то в C должно быть так:

int _test3( char** b ) {return 1;}
или так
int _test3( char* b[] ) {return 1;}
...
Рейтинг: 0 / 0
MVS2010 + PB12 - argument type differs from required argument type
    #37525320
_Drive_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Еще раз добрый день
...
и неплохо было бы перед вызовом test3 сделать
ls_arg = space(256) // или сколько вам надо
...
Рейтинг: 0 / 0
MVS2010 + PB12 - argument type differs from required argument type
    #37525457
bor__bor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Спасибо за ответ - к сожалению не помогло
...
Рейтинг: 0 / 0
MVS2010 + PB12 - argument type differs from required argument type
    #37525739
bor__bor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Разобрался. Вопрос снят
...
Рейтинг: 0 / 0
MVS2010 + PB12 - argument type differs from required argument type
    #37525742
Dim2000
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
14.11.2011 12:43, bor__bor пишет:

> *Function* Long test1( ) Library"CplusPB.DLL" ALIAS*FOR* "test1;Ansi"
> *Function* Long test2( int a ) Library"CplusPB.DLL" ALIAS*FOR* "test2;Ansi"

Не Int, а Long. Да и ;Ansi здесь - бессмысленный gimmick.
Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
MVS2010 + PB12 - argument type differs from required argument type
    #37525789
bor__bor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Да согласен - убрал
...
Рейтинг: 0 / 0
7 сообщений из 7, страница 1 из 1
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / MVS2010 + PB12 - argument type differs from required argument type
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]