NO

Author Topic: appears to be oldnames64.lib pclose  (Read 4050 times)

popeye4747

  • Guest
appears to be oldnames64.lib pclose
« on: October 24, 2011, 11:33:33 PM »
Hello all:

While compiling using the latest version of Pelles C  on 64 bit Win 7, in my program I call popen,  and then pclose.
When the program runs, it quits just at the call for pclose.

I used the pelles C debugger, and this is where it appears to die, at the call to pclose.

But, if I compile 32 bit on my 64 bit system, using 64bit pelles C, then all works
and the call to popen, and pclose all works OK both on 32 bit, and when run on 64 bit.

So my logic lead to oldnames64.lib 

My question to the group is, has anyone else seen this type of problem
and if so what is the solution?

If  you need additional details, please let me know.

Other library calls in oldnames64.lib do not appear to be effected, although I have
not done any extensive testing of other calls.

Thanks for your help.

CommonTater

  • Guest
Re: appears to be oldnames64.lib pclose
« Reply #1 on: October 25, 2011, 03:46:31 AM »
It would help if you posted either your active code or a smaller snippet of code that demonstrates the behavior... (be sure to use the code tags option).

If it's working as 32 bit but not working as 64 bit, I would guess it's a pointer problem of some kind...  but without seeing your code, that's just speculation.


popeye4747

  • Guest
Re: appears to be oldnames64.lib pclose
« Reply #2 on: October 28, 2011, 09:12:21 PM »
int listAvailable(char *prnt)
{
    char cmdpath[LINSIZ];
    char line1[LINSIZ];
    char fileNam[128];
    char *lptr;
    char *l2ptr;
    int linecnt = 0;
    int cnt = 0;
   
    strcpy(cmdpath,cwd);
    strcat(cmdpath,"\\");
    strcat(cmdpath,"listfiles.exe");
   
    sglcnt = 0;
   
    if(pfile = _popen(cmdpath,"r"))
     {
      while(fgets(line1,LINSIZ,pfile) != NULL)
          {
           strip_newline(line1);
           
           linecnt++;
           
           
           lptr = line1;
           l2ptr = fileNam;
           while(*lptr != 32)
               {
                *l2ptr++ = *lptr++;   
               } /* End while */
               
           *l2ptr++ = '\0';
           strcpy(fileList[sglcnt++],fileNam);

           
          } /* End while */
         
     } /* End if */
     
    _pclose(pfile);
   
   
    return linecnt;
   
} /* End listAvailable */

CommonTater

  • Guest
Re: appears to be oldnames64.lib pclose
« Reply #3 on: October 28, 2011, 11:53:44 PM »
pfile appears to be undefined. 
Also your if(pfile = _popen(...)) probably doesn't do quite what you expect. It's possible the file is not opening. An explicit test would be better ...
Code: [Select]
FILE* pfile

pfile = _popen(cmdpath,"r");
if (!pfile)
  return -1;      // or suitable error value

You might also try some diagnostic printf() calls in there to make sure of what it's doing. 







Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
Re: appears to be oldnames64.lib pclose
« Reply #4 on: October 29, 2011, 08:51:21 AM »
Code: [Select]
...
           while(*lptr && *lptr != 32)
               {
                *l2ptr++ = *lptr++;   
               } /* End while */
           *l2ptr = '\0';
...
          } /* End while */
          _pclose(pfile);
     } /* End if */
...
May the source be with you