LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-26-2005, 02:35 PM   #1
os2
Member
 
Registered: Dec 2003
Location: Canada
Distribution: openSUSE Tumbleweed
Posts: 209

Rep: Reputation: 30
structure


hi

i would like to be able to change value of the struct in initReadRtu function...

Code:
typedef struct production_s {
  ...
} production_t;
void initReadRtu(production_t *[]);

int main()
{
  production_t prod[2];
  initReadRtu(&prod);
  return 0;
}

each time i compile this code, i get:

warning: passing arg 1 of `initReadRtu' from incompatible pointer type


any idea?

thanks
 
Old 05-26-2005, 02:57 PM   #2
juanbobo
Member
 
Registered: Mar 2005
Location: Chicago
Distribution: Gentoo AMD64
Posts: 365

Rep: Reputation: 30
Try "**" instead of "*[]"?
 
Old 05-26-2005, 03:03 PM   #3
os2
Member
 
Registered: Dec 2003
Location: Canada
Distribution: openSUSE Tumbleweed
Posts: 209

Original Poster
Rep: Reputation: 30
get the same result
 
Old 05-26-2005, 03:37 PM   #4
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Rep: Reputation: 31
Code:
typedef struct production_s {
 ..
} production_t;

void initReadRtu(production_t *prod) {
 ...
}

int main()
{
        production_t prod[2];
        initReadRtu(prod);
        return 0;
}
 
Old 05-27-2005, 08:07 AM   #5
os2
Member
 
Registered: Dec 2003
Location: Canada
Distribution: openSUSE Tumbleweed
Posts: 209

Original Poster
Rep: Reputation: 30
introuble, that work, but my program crash after a few second

if i don't use struct... and i use many variables... that work without problem....

if somebody want to check the file...

www.laboiteaprog.com/tmp.tar.gz

export to do....
Code:
export LOCAL_DIR_LED=/opt/good/engcoop2/test
export LOCAL_DIR_CSV=/opt/good/engcoop2/test
export MNT_DIR_WWW=/opt/good/engcoop2/test
export MNT_DIR=/opt/good/engcoop2/test
export MNT_DIR_CSV=/opt/good/engcoop2/test
export EQU_NAME=triplex

thanks

Last edited by os2; 05-27-2005 at 08:22 AM.
 
Old 05-27-2005, 09:08 AM   #6
os2
Member
 
Registered: Dec 2003
Location: Canada
Distribution: openSUSE Tumbleweed
Posts: 209

Original Poster
Rep: Reputation: 30
the problem seem my thread....

Code:
rc = pthread_create(&threads, NULL, (void *)&writeFile, (void *)&prod);
    if (rc) {
      makehtml_syslog("**CRITICAL** return code from pthread_create() is %d\n", rc);
      exit(-1);
}

writeFile function
Code:
void writeFile(production_t *prod)
{
    while(1)
    {
        sleep(2);
        writeWebPage(&prod);
        
        if (newDay==true)
        {
            changeDay();
            newDay=false;
        }   
        
        if(runbHistory==true)
        {
            bHistoryWebPage();
            runbHistory=false;   
        }
        
        if(runHistory==true)
        {
            historyWebPage();
            runHistory=false;   
        }
    }
}
writewebpage function
Code:
void writeWebPage(production_t *prod)
{    
    //production_t prod[2];
    
    char tmp_mnt_dir_www[75];
    
    snprintf(tmp_mnt_dir_www, sizeof(tmp_mnt_dir_www),"%s/makehtml.lock", mnt_dir_www);
    
    /*create lock file*/
    createLockFile(tmp_mnt_dir_www);
    
    /*picture page */
    summaryWebPage(&prod);
        
    /*information page on counter */
    detailWebPage(&prod);
        
    msgDisplayPanel();
    
    /*remove file lock*/
    removeFile(tmp_mnt_dir_www);
}
 
Old 05-29-2005, 07:39 PM   #7
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
You're going over the top with your '&'s. If prod is declared as an array, "prod" is already a pointer to it, and taking the address of the pointer isn't what you want. If you're lucky, the compiler may silently ignore the '&' but if it doesn't your code will break. You also don't need the '&' before "writeWebPage" - the function name is already a pointer.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file_operations structure mp4-10 Programming 6 10-28-2009 02:50 AM
Directory Structure fedix Linux - Newbie 3 10-14-2005 02:48 PM
Filesystem structure Techformer Linux - Newbie 3 11-29-2004 03:35 PM
error with structure rubinbob Programming 2 07-21-2004 07:55 AM
What is the Organizational Structure of LQ? yadavankur LQ Suggestions & Feedback 5 11-23-2002 08:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration