?
Solved

error 2146

Posted on 2007-08-08
12
Medium Priority
?
1,189 Views
Last Modified: 2013-12-14
I am getting the following error:

error C2146: syntax error : missing ';' before identifier 'm_lpSession'

Corresponding code:
//*****************************************************************************

#pragma once

//#include <afxwin.h>
#ifdef _MSC_VER
#if _MSC_VER == 1100
#include <afxext.h>
#endif
#endif

#include <iostream>

#include "Mailbox.h"
//#include "mapidefs.h"
//#include "edk.h" Commented by Sham(mohet01)
//#include "edkmdb.h"  

namespace nsExchange_Mailbox
{
    const DWORD dwMaxTableRows = 2000;
    const DWORD dwMaxLineSize = 512;

    enum{ UNABLE_TO_GET_MSG_STORES_TABLE = 1,
          UNABLE_TO_QUERY_MSG_TABLE,
          NO_DEFAULT_MSG_STORE,
          UNABLE_TO_OPEN_MSG_STORE,
          CANNOT_SET_COLUMNS,
          CANNOT_QUERY_ROWS,
          ALLOCATION_FAILURE,
          NO_EXCHANGE_INTERFACE,
          NO_STORE_TABLE_POINTER,
          MAPI_CALL_FAILED,
          MAPI_INVALID_PARAMETER,
          MAPI_LOGON_FAILED,
          MAPI_NETWORK_ERROR,
          MAPI_NO_ACCESS,
          MAPI_NOT_ENOUGH_MEMORY,
          MAPI_TIMEOUT,
          MAPI_UNKNOWN_ERROR,
          UNABLE_TO_INIT_MAPI,
          EMPTY_PROFILE_STRING,
          EMPTY_SERVER_STRING,
          PRIVATE_MAILBOX_STORE_NOT_FOUND,
          ILLEGAL_PROFILE_NAME,
          ILLEGAL_SERVER_NAME,
          ILLEGAL_MAILBOX_NAME,
              ILLEGAL_PASSWORD_NAME,
          UNINITIALIZED,
          UNKNOWN_ERROR,
              NO_LEGACY_DN};
}


class Retrieve_Mailbox
{

    public:

        Retrieve_Mailbox();
        ~Retrieve_Mailbox();

            // Various return codes. Most are error conditions.
    enum tagReturnTypes
    {
        success=0,                          // Success
        mapi_init_fail,                     // MAPIInitialize() failed
        not_yet_initialized,                // Caller has not called Init()
        logon_failed,                       // MAPILogonEx() returned: failed
        logon_timeout,                      // MAPILogonEx() returned: timeout
        unknown_failure,                    // General unknown failure
        profile_exists,                 // Profile already exists
        profile_not_found,              // Profile not found
        unable_to_get_profile_admin,    // Unable to get profile admin object
        invalid_profile_name,           // Invalid profile name
        no_access,                      // access violation or object not fnd
        return_count                    // ALWAYS LAST!
    };

        LRESULT getMailboxes(const BOOL bRunningAsService,
                                                const std::string & sServer,
                                                const std::string & sUser,
                                                const std::string & sPassword,
                                                Mailboxs_t &Mailboxes,
                                                const std::string & sLegacyDN);
            bool UtilImpersonate(      const char IN *inUserName,
                                                const char IN *inPassword,
                                                const char IN *inDomainName,
                                                HANDLE OUT &hUserToken);
            void EnablePrivileges(      HANDLE      hProccesTokenHandle);
            LRESULT CreateCommonProfile(const std::string & sServer,
                  const std::string & sUser,
                  const std::string & sPassword);

    private:

        BOOL  m_bIsLoggedOn;
        BOOL m_bRunningAsService;
        BOOL m_bInitialized;
        std::string  m_sProfile;
        std::string  m_sServer;
            std::string  m_sUser;
            std::string  m_sPassword;
            std::string  m_sLegacyDN;
       
        // Session handle returned by MAPI Logon
        LPMAPISESSION   m_lpSession;

        // Message Store pointer
        LPMDB           m_pmdb;

        // Manage Store pointer
        LPEXCHANGEMANAGESTORE m_pfldManageStore;

        // MAPI initialization structure
        MAPIINIT_0 m_MAPIINIT;

            LRESULT InitMAPI();
        void HrDeInitMAPI();
        void HrLogoff();
     
            std::string GetStringFromHR(HRESULT hr,BOOL bCOUT=TRUE);
            int      CHECK_INITIALIZED();
            int HrLogon();
            LRESULT HrOpenDefaultStore(LPMDB *ppmdb);
        LRESULT OpenManageStore(LPEXCHANGEMANAGESTORE *lppMngStore);

            int ProfileExists(LPCSTR lpcszProfileName);
            int CreateProfile(LPCSTR lpcszProfileName, LPCSTR lpcszMailboxDisplayName);
            int CheckForProfile();
            int RemoveProfile(LPCSTR lpcszProfileName);

        LRESULT EnumMailBoxes(Mailboxs_t &Mailboxes,
                               LPMDB pmdb);
         
};


Please let me know the solution
0
Comment
Question by:sham_hcu
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 19653944

I believe that you need a semicolon ';' after the bracket '}' that terminates the namespace declaration.  (Immediately before the class Retrieve_Mailbox header.

And you may need to include <iostream.h>, not <iostream>.



Kent
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 19653997
>> I believe that you need a semicolon ';' after the bracket '}' that terminates the namespace declaration.

Not as far as I know ...


>> And you may need to include <iostream.h>, not <iostream>.

I would not recommend using <iostream.h> as it's deprecated.



I would check whether you have the proper include for LPMAPISESSION. Do you ?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 19654014
>> I would check whether you have the proper include for LPMAPISESSION. Do you ?

Try adding :

#include <edk.h>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:sjith2000
ID: 20039776
One more suggestion.Even if you resolve the problem with LPMAPISESSION by adding the required header file, you will still get errors.This is because you are missing the statement,
using namespace std;
in the program.

You are using std::string to declare the string variables.But since you are using #include<iostream>, you have to use using namespace std;
As Infinity08 says you have to use <iostream> only since <iostream.h> is deprecated.

See the following code segements.

Code segment 1:
---------------------
#include<iostream>
using namespace std;
void main()
{
      cout<<"hello";
}
If u comment the using namespace std; statement, the program will give compilation errors.

Code Segement 2:
----------------------
#include<iostream.h>

void main()
{
      cout<<"hello";
}

0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 150 total points
ID: 20039840
>> But since you are using #include<iostream>, you have to use using namespace std;

No, you don't have to, and in fact it's not a good idea generally.

A using directive (eg. using namespace std;) dumps the whole std namespace in the current one. It's easy, but it's not very nice.

A using declaration (eg. using std::cout;) just informs the compiler that you want to use the cout from the std namespace. This is a lot nicer, but can be less clear when reading the code (as you have to find the using declaration when you want to know which one you use).

Usually, I prefer just adding a namespace scope whenever I use a namespace member, like :

        std::cout << "Hello World !" << std::endl;

It requires a bit more typing ... but the advantages far outweigh this slight disadvantage.


Btw, a main has to return int ;)
0
 

Expert Comment

by:sjith2000
ID: 20039987
Thanks for the clarification Infinity08.I understood the intention that an entire namespace should not be dumped into the program.
But when we create a new project in Microsoft Visual Studio .NET2003, we get the sample code.The first line is the statement
using System;
which will dump the entire namespace into the prject.So are you saying it is a bad idea to do in this way?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20040467
>> But when we create a new project in Microsoft Visual Studio .NET2003, we get the
>> sample code.The first line is the statement
>> using System;

That's .NET, and has nothing to do with C++. It's not even valid C++ afaik (it's missing ::).

In C++, dumping an entire namespace into the current one is to be avoided, ESPECIALLY in header files.
0
 

Expert Comment

by:sjith2000
ID: 20046420
Thanks a lot for correcting me,Infinity08
0
 

Author Comment

by:sham_hcu
ID: 21178365
@infi:  I want to learn creating projects and some C++ programming in Microsoft .NET 2003 environment. Can u suggest any resource link?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21178781
>> Can u suggest any resource link?

I'm not a Visual C++ guy myself, but you can always check here (Visual C++ .NET 2003 Solution Center) :

        http://support.microsoft.com/ph/2990


If you're looking for C++ information, check this site (they also have a nice tutorial that is worth the read) :

        http://www.cplusplus.com/
0
 

Author Closing Comment

by:sham_hcu
ID: 31407604
Done
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21185426
May I ask why you gave a B grade ? That usually means that something was missing in the answers we gave. If something is not clear, feel free to ask about it, and I'll be happy to clarify !
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question