Thread: Can't change global variable :(

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733

    Can't change global variable :(

    I run sh build.sh which contains this:
    Code:
    prep_gcc() {
    	if [ "$1" = "64" ]; then
    		ARCH=amd64
    	elif [ "$1" = "32" ]; then
    		ARCH=i386
    	fi
    	if [ "$2" = "mgw" ]; then
    		_FLAGS=$mWall $mWerror $mmconsole $mmwindows $mmwin32
    		if [ "$1" = "64" ]; then
    			PFX=x86_64-w64-mingw32-
    			LFLAGS=-m64
    			CFLAGS=-m64
    		elif [ "$1" = "32" ]; then
    			PFX=i386-w64-mingw32-
    			LFLAGS=-m32
    			CFLAGS=-m32
    		fi
    	fi
    	LD=$PFXgcc
    	CC=$PFXgcc
    	CXX=$PFXg++
    	LFLAGS=$_FLAGS $LFLAGS
    	CFLAGS=$_FLAGS $CFLAGS
    	O_DIR=$PFXgcc
    }
    prep_gcc 64
    Shortly after the start, but when trying to append O_DIR I find that it is empty resulting in a path like this
    Code:
    objs//lu.c.o

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    The shell parser isn't that smart.

    Code:
    O_DIR=${PFX}gcc
    Ditto all your other $PFX assignments.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    ah that's where I slipped up thx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 10-25-2014, 10:36 PM
  2. static global variable and static extern global variable
    By gunjansethi in forum C Programming
    Replies: 8
    Last Post: 01-12-2011, 01:00 AM
  3. Replies: 8
    Last Post: 09-27-2010, 04:11 PM
  4. Static Local Variable vs. Global Variable
    By arpsmack in forum C Programming
    Replies: 7
    Last Post: 08-21-2008, 03:35 AM
  5. Static global variable acting as global variable?
    By Visu in forum C Programming
    Replies: 2
    Last Post: 07-20-2004, 08:46 AM

Tags for this Thread