Error during compiling

This is a discussion on Error during compiling within the C Programming forums, part of the General Programming Boards category; I have following code in file php_mysqlnd.c Code: #if defined(PHP_DEBUG) /* {{{ PHP_RSHUTDOWN_FUNCTION */ static PHP_RSHUTDOWN_FUNCTION(mysqlnd) { MYSQLND_DEBUG *dbg = ...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    1

    Error during compiling

    I have following code in file php_mysqlnd.c
    Code:
    #if defined(PHP_DEBUG)
    /* {{{ PHP_RSHUTDOWN_FUNCTION
     */
    static PHP_RSHUTDOWN_FUNCTION(mysqlnd)
    {
    	MYSQLND_DEBUG *dbg = MYSQLND_G(dbg);
    	DBG_ENTER("RSHUTDOWN");
    	if (dbg) {
    		dbg->m->close(dbg);
    		dbg->m->free_handle(dbg);
    		MYSQLND_G(dbg) = NULL;
    	}
    	return SUCCESS;
    }
    /* }}} */
    #endif
    I am getting following error

    ext\mysqlnd\php_mysqlnd.c(256) : error C2106: '=' : left operand must be l-value

    on code line
    Code:
    		MYSQLND_G(dbg) = NULL;
    Please anyone guide me

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,781
    Is that line even supposed to be there? Perhaps you can remove it safely.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by altaf View Post
    ext\mysqlnd\php_mysqlnd.c(256) : error C2106: '=' : left operand must be l-value
    What this means is that the left side must be something that can be assigned to. I think the only way that could work for this:
    Code:
    MYSQLND_G(dbg)
    would be if that were a macro like this:
    Code:
    #define MYSQLND_G(a) a.id
    So if dgb were a struct with a member "id" you could assign to it this way.

    The other clue here:
    Code:
    	MYSQLND_DEBUG *dbg = MYSQLND_G(dbg);
    Makes it clear that what MYSQLND_G actually does is return an address, eg:
    Code:
    #define MYSQLND_G(a) &a
    You cannot assign NULL to an address. This all could work if it returned a number equivalent to an address, but it's still beyond me why you'd want to then assign that NULL.

    Like laserlight says, I'd try leaving that line out. The variable names here imply this is for development/debugging -- it probably is not normally used.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Can't you grep where this look-like-macro is defined?

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    MK27: You seem to disagree with yourself. It DOES make sense for MYSQLND_G to return a pointer AND be an l-value. You gave the example yourself:
    Code:
    #define MYSQLND_G(a) a.id
    Where a.id is a pointer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling errors and using Cmake Set Policy
    By eligor in forum Linux Programming
    Replies: 2
    Last Post: 01-25-2010, 12:43 PM
  2. Compiling Issues
    By pc_doctor in forum C Programming
    Replies: 3
    Last Post: 11-30-2007, 09:00 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  5. Compiling in Unix vs Visual C++
    By stimpyzu in forum C++ Programming
    Replies: 2
    Last Post: 09-30-2002, 06:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21