- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hello,
I have a quick question regarding the GetProcAddress command in Compaq Visual Fortran. In all the examples of using GetProcAddress that I have found so far, the name of the procedure is known in advance and hard coded. For example:
q = getprocaddress(p, "SUB1"C)
I have to repeat this command a number of times with variations on the null terminated string (SUB1,SUB2,SUB3 etc.) and am having no luck constructing the null terminated string and then using it... here is a code snippet
...
INTEGER:: j
CHARACTER*12:: jStr
CHARACTER*7:: SubNum
INTEGER(INT_PTR_KIND()) paa(100)
POINTER (p,i)
DO j=1,100
!write the integer variable j to the string variable jStr
WRITE(jStr,*) j
!change the leading blanks to trailing blanks
jStr=ADJUSTL(jStr)
!concatenate jStr onto SUB
SubNum="SUB"//TRIM(jStr)
paa(j) = GetProcAddress(p,SubNum)
END DO
...
GetProcAddress always returns NUL and I suspect that it is because the argument SubNum is not really a null terminated string.
if I replace the line
paa(j) = GetProcAddress(p,SubNum)
with
paa(1) = GetProcAddress(p,"SUB1"C)
I get the proper pointer but would have to type in 100 such lines instead of using the DO loop. Any hints as to what I am doing wrong here would be much appreciated.
Cheers,
David
I have a quick question regarding the GetProcAddress command in Compaq Visual Fortran. In all the examples of using GetProcAddress that I have found so far, the name of the procedure is known in advance and hard coded. For example:
q = getprocaddress(p, "SUB1"C)
I have to repeat this command a number of times with variations on the null terminated string (SUB1,SUB2,SUB3 etc.) and am having no luck constructing the null terminated string and then using it... here is a code snippet
...
INTEGER:: j
CHARACTER*12:: jStr
CHARACTER*7:: SubNum
INTEGER(INT_PTR_KIND()) paa(100)
POINTER (p,i)
DO j=1,100
!write the integer variable j to the string variable jStr
WRITE(jStr,*) j
!change the leading blanks to trailing blanks
jStr=ADJUSTL(jStr)
!concatenate jStr onto SUB
SubNum="SUB"//TRIM(jStr)
paa(j) = GetProcAddress(p,SubNum)
END DO
...
GetProcAddress always returns NUL and I suspect that it is because the argument SubNum is not really a null terminated string.
if I replace the line
paa(j) = GetProcAddress(p,SubNum)
with
paa(1) = GetProcAddress(p,"SUB1"C)
I get the proper pointer but would have to type in 100 such lines instead of using the DO loop. Any hints as to what I am doing wrong here would be much appreciated.
Cheers,
David
- Marcas:
- Intel® Fortran Compiler
Link copiado
1 Responder
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
You need to null terminate the string, in your case:
paa(j) = GetProcAddress(p,TRIM(SubNum)//CHAR(0))
James
paa(j) = GetProcAddress(p,TRIM(SubNum)//CHAR(0))
James

Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora