×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    79

    errors: 'Static' not declared (first use this function), 'CCoeEnv' has not been decla

    I have a console app that auto-answers incoming calls and I'm trying to add code to simulate some keypresses once a call has been answered. I'm using code from the wiki article on how to 'simulate a keypress' in 3rd edition. The example code starts with:

    RWsSession wsSession=CCoeEnv::Static()->WsSession();

    I have copied this code to my CStatusChecker::RunL() function where the call is answered when status is 'ringing'. I'm getting two errors when I try to compile "'Static' not declared (first use this function)" and "'CCoeEnv' has not been declared". I have #include W32STD.h and ws32 lib. The only thing I changed in the example code is the key being pressed. Please let me know what I might be missing.

    Thanks,
    ~Mike

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: errors: 'Static' not declared (first use this function), 'CCoeEnv' has not been d

    Is it a GUI app, or something else ?, basically the control environment variable is only automatically contructed for GUI apps. Also have you checked the header file required for CCoeEnv, and made sure it is visible to the point where you are using the code in ?

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: errors: 'Static' not declared (first use this function), 'CCoeEnv' has not been d

    Even in case of a GUI app it should rather be
    Code:
    RWsSession &wsSession=CCoeEnv::Static()->WsSession();
    The header and library are nice for having RWsSession, but you should check the documentation of CCoeEnv, since that is what is missing.

  4. #4
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    79

    Re: errors: 'Static' not declared (first use this function), 'CCoeEnv' has not been d

    It is not a GUI app. It is a console app. I did make sure that the W32STD.h is #included in the file where the problematic code is. Where would I find an example of how to properly setup the control environment variable for a non-GUI app. Thanks.
    Quote Originally Posted by symbianyucca View Post
    Is it a GUI app, or something else ?, basically the control environment variable is only automatically contructed for GUI apps. Also have you checked the header file required for CCoeEnv, and made sure it is visible to the point where you are using the code in ?

  5. #5
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    79

    Re: errors: 'Static' not declared (first use this function), 'CCoeEnv' has not been d

    Thanks, I have looked through the CCoeEnv documentation in the Nokia library but I am still somewhat confused how to implement it in a console app. Would I still have to link against cone.lib? Do I have to manually import CCoeEnv and call CCoeEnv::ConstructL()?
    Quote Originally Posted by wizard_hu_ View Post
    Even in case of a GUI app it should rather be
    Code:
    RWsSession &wsSession=CCoeEnv::Static()->WsSession();
    The header and library are nice for having RWsSession, but you should check the documentation of CCoeEnv, since that is what is missing.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: errors: 'Static' not declared (first use this function), 'CCoeEnv' has not been d

    In a console app, write
    Code:
    RWsSession wsSession;
    User::LeaveIfError(wsSession.Connect());
    CCoeEnv is in coemain.h and cone.lib, but you can not use it easily in a console application. The previous two lines are definitely simpler.

  7. #7
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    79

    Re: errors: 'Static' not declared (first use this function), 'CCoeEnv' has not been d

    thanks it compiles now
    Quote Originally Posted by wizard_hu_ View Post
    In a console app, write
    Code:
    RWsSession wsSession;
    User::LeaveIfError(wsSession.Connect());
    CCoeEnv is in coemain.h and cone.lib, but you can not use it easily in a console application. The previous two lines are definitely simpler.

Similar Threads

  1. Replies: 7
    Last Post: 2009-10-15, 08:15
  2. how CCoeEnv::Static() implement
    By qxiaoyuan in forum Symbian
    Replies: 8
    Last Post: 2009-01-29, 02:22
  3. Replies: 10
    Last Post: 2008-08-19, 03:08
  4. CCoeEnv::Static() is returning NULL pointer!
    By gwn-sameer in forum Symbian
    Replies: 2
    Last Post: 2007-11-12, 10:05
  5. Replies: 1
    Last Post: 2007-07-26, 15:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×