Operating System - HP-UX
1843929 Members
1487 Online
110226 Solutions
New Discussion

Re: Help with compiler errors

 
Russ Park
Frequent Advisor

Help with compiler errors

Hi all,
I've done searches on these, but there doesn't appear any direct explanation of what causes these. I'm willing to do my homework, but not sure where to start. Is there a place one can look up these errors and get an explanation of what causes them? Either way, I'm getting:

Reference through a non-pointer (for both lines)
and
Expression in if must be scalar (for the 1st line)

for the following lines in my .c file:

if (acct->uflg->fg_expire)
expire_time = acct->ufld->fd_expire;

I'm happy to provide more complete details if necessary, but thought we'd start here.

Thanks
Russ
2 REPLIES 2
Russ Park
Frequent Advisor

Re: Help with compiler errors

Well, I found help from a knowledgeable c programmer on staff here at work, and though he wasn't familiar with HPUX, he understood the errors and helped me work through this. Therefore, I'll say we can "close" this, and when I have time, I'll add a line expaining the full solution with before and after versions of the files. One thing I didn't explain was that this is a port from Tru64 that I'm attempting. The file works there great but I needed this on HPUX. For anyone who cares, it is a file that produces a listing of users showing when their passwords expire. We use this as part of a Audit mandated requirement to notify users that their password will expire and when they have not logged in for more than 50 days. When I have this all settled, I'll post the files.

Thanks anyway,
Russ
Husejin Trakic
New Member

Re: Help with compiler errors


The following would correctly reference pointer to struct containing pointer to other structs:
...
if (acct->uflg->fg_expire)
expire_time = acct->ufld->fd_expire;
...

In actual fact, documentation states that pr_passwd wraps nested structs rather than reference them thru pointer:

struct pr_passwd {
struct pr_field ufld; /* user specific fields */
struct pr_flag uflg; /* user specific flags */
struct pr_field sfld; /* system wide fields */
struct pr_flag sflg; /* system wide flags */
};

So the way to reference it is:
...
if (acct->uflg.fg_expire)
expire_time = acct->ufld.fd_expire;
...

I think there is a coding example floating on the web (variable names match) that is wrong in this sense.