Thread: error C2106: '=' : left operand must be l-value

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    4

    error C2106: '=' : left operand must be l-value

    hi,

    I get this error: error C2106: '=' : left operand must be l-value after compiling my program using Microsoft Visual Studio 2008.

    But this error didn't appear at all if I compile my program using Microsoft Visual C++ 4.0.

    Please advise. Thanks.

    The line of coding is as below:

    IMG_MAXREC = GetPrivateProfileInt("File", "MaxRec",10000, ABC_INIFILE);

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    IMG_MAXREC
    Is the a macro ?

    If it is, then you cant reassign it a value as it doesn't have an address(l-value) in memory.

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    4
    but what is macro?

    this is the declaration:

    int IMG_MAXREC;

    but it is from another program. (exe)

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    But this error didn't appear at all if I compile my program using Microsoft Visual C++ 4.0.
    Isn't that from Windows 95?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    4
    it's from Windows XP.

    I can't understand why once I tried to compile my programs with Microsoft Visual Studio 2008 instead of Microsoft Visual C++ 4.0, it will gives me errors.

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    4
    hi,

    i found what's went wrong alr... there is nothing to do with the syntax, just need to update the lib & dll files in share library. after compile, there should be no error appear anymore.

    anyway, thanks for help. ^-^

  7. #7
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    microsoft visual C++ 4.0
    wow man, that is epic !
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by janicecp View Post
    I can't understand why once I tried to compile my programs with Microsoft Visual Studio 2008 instead of Microsoft Visual C++ 4.0, it will gives me errors.
    Because VC++ 4 is, I believe, about 15 years old and things have changed. The language changed and was standardized, and the compiler's support for said standard has improved too. Your old program is simply not valid by today's standard.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Just so you're aware, placing a variable in all caps is used to show that a certain identifier represents a macro (or constant). It's not part of the standard. There's nothing technically wrong with doing something different - but you should just be aware that most people would see the name IMG_MAXREC and probably assume it was a macro / constant - it's a very common practice that some would see as "standard".

  10. #10
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Probably IMG_MAXREC expands to something like "image_getmaxrec()". In this case you would have declared a function and tried to assign a value to a call.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL, loading BMP Textures?
    By Zeusbwr in forum Game Programming
    Replies: 12
    Last Post: 12-09-2004, 05:16 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Please help me
    By teedee46 in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2002, 11:28 PM