String methods and Xcode


#1

I have a provlem wit missing String methods, in a function like that

void fromString (const String &serializedString)
		{
			indexes.clear();
			values.clear();
			numUsed = 0;

			StringArray toks;
			toks.addTokens (serializedString, T(","));
			for (int i=0; i<toks.size(); i++)
			{
				const int index			= toks[i].upToFirstOccurenceOf (T(":")).getIntValue();
				const ElementType value	= toks[i].fromFirstOccurenceOf (T(":")).getLargeIntValue();
				indexes.add (index);
				values.add (value);
				numUsed++;
			}
		}

The errors i get are:

Building target “EdoController” of project “EdoController” with configuration “Release”


Checking Dependencies

CompileC build/EdoController.build/Release/EdoController.build/Objects-normal/i386/EdoController.o /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../EdoController.cpp normal i386 c++ com.apple.compilers.gcc.4_0
    cd /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController
    /Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -Wreturn-type -Wunused-variable -DJUCE_ObjCExtraSuffix=FINDMEQUICK -DJUCE_RELEASE -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -gdwarf-2 -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/EdoController.hmap -F/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/Release -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/Release/include -I../../.. -I/Users/atom/devel/juce -I../../../../Lua/diluculum/include -I../../../../Lua/boost -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/DerivedSources/i386 -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/DerivedSources -c /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../EdoController.cpp -o /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/Objects-normal/i386/EdoController.o
/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../Primitives/AssocArray.h: In member function 'void AssocArray<ElementType>::fromString(const juce::String&)':
/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../Primitives/AssocArray.h:86: error: 'const class juce::String' has no member named 'upToFirstOccurenceOf'
/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../Primitives/AssocArray.h:87: error: 'const class juce::String' has no member named 'fromFirstOccurenceOf'

CompileC build/EdoController.build/Release/EdoController.build/Objects-normal/i386/EdoRandomizer.o /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../EdoInternalModulators/Core/EdoRandomizer.cpp normal i386 c++ com.apple.compilers.gcc.4_0
    cd /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController
    /Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -Wreturn-type -Wunused-variable -DJUCE_ObjCExtraSuffix=FINDMEQUICK -DJUCE_RELEASE -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -gdwarf-2 -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/EdoController.hmap -F/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/Release -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/Release/include -I../../.. -I/Users/atom/devel/juce -I../../../../Lua/diluculum/include -I../../../../Lua/boost -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/DerivedSources/i386 -I/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/DerivedSources -c /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../EdoInternalModulators/Core/EdoRandomizer.cpp -o /Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/build/EdoController.build/Release/EdoController.build/Objects-normal/i386/EdoRandomizer.o
/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../Primitives/AssocArray.h: In member function 'void AssocArray<ElementType>::fromString(const juce::String&)':
/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../Primitives/AssocArray.h:86: error: 'const class juce::String' has no member named 'upToFirstOccurenceOf'
/Users/atom/devel/ctrlr/EdoController/Build/Mac/EdoController/../../../Primitives/AssocArray.h:87: error: 'const class juce::String' has no member named 'fromFirstOccurenceOf'

Are there any visibility/namespace issues i need to consider to make this work ?


#2

It might work better if you spell the name right and give it enough parameters! :stuck_out_tongue:


#3

ok i see my error and i’m sorry

but

how the hell does this compile on Windows? i use the same code from SVN and it builds on windows, wtf?


#4

Well, there ain’t no way on earth that’ll compile on windows either, so I’ve no idea what you must be doing!


#5

i’m lost

here is a file.cpp

#include "Primitives/AssocArray.h"

AssocArray<int> arr;

here is the AssocArray.h

#ifndef __ASSOC_ARRAY_H__
#define __ASSOC_ARRAY_H__

#include "Includes.h"

template <typename ElementType> class AssocArray
{
	private:
#if defined (_MSC_VER) && _MSC_VER <= 1400
	typedef const ElementType& ParameterType;
#else
	typedef PARAMETER_TYPE (ElementType) ParameterType;
#endif

	public:
		AssocArray(const ElementType _elementToReturnWhenEmpty=-1) : numUsed(0), elementToReturnWhenEmpty(_elementToReturnWhenEmpty)
		{
		}

		void clear()
		{
			for (int i = numUsed; --i >= 0;)
			{
				indexes.remove (i);
				values.remove (i);
			}
			numUsed=0;
		}

		const uint32 size()
		{
			return (numUsed);
		}

		const uint32 indexOf (const ElementType value)
		{
			if (values.indexOf (value) >= 0)
			{
				return (indexes[values.indexOf (value)]);
			}
			else
			{
				return ((uint32)elementToReturnWhenEmpty);
			}
		}

		void set (const uint32 index, const ElementType value)
		{
			indexes.add (index);
			values.add (value);
			numUsed++;
		}

		inline ElementType operator[] (const uint32 index) const
		{
			if (indexes.indexOf(index) >= 0)
			{
				return (values[indexes.indexOf(index)]);
			}
			else
			{
				return (elementToReturnWhenEmpty);
			}
		}

		const String toString()
		{
			String tmp;
			for (int i=0; i<numUsed; i++)
			{
				tmp << indexes[i] << T(":") << values[indexes[i]] << T(",");
			}
			return ( tmp.upToLastOccurrenceOf (T(",")) );
		}

		void fromString (const String &serializedString)
		{
			indexes.clear();
			values.clear();
			numUsed = 0;

			StringArray toks;
			toks.addTokens (serializedString, T(","));
			for (int i=0; i<toks.size(); i++)
			{
				const int index			= toks[i].upToFirstOccurenceOf (T(":")).getIntValue();
				const ElementType value	= toks[i].fromFirstOccurenceOf (T(":")).getLargeIntValue();
				indexes.add (index);
				values.add (value);
				numUsed++;
			}
		}

	private:
		ElementType elementToReturnWhenEmpty;
		Array <uint32> indexes;
		Array <ElementType> values;
		uint32 numUsed;
};

#endif

and yest there is a typo, i compile that file in VSExpress

1>------ Build started: Project: EdoController, Configuration: Release Win32 ------
1>Compiling...
1>file.cpp
1>Build log was saved at "file://c:\devel\ctrlr\EdoController\Build\Win\Release-Win32\BuildLog.htm"
1>EdoController - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Build Log
Build started: Project: EdoController, Configuration: Release|Win32
Command Lines
Creating temporary file "c:\devel\ctrlr\EdoController\Build\Win\Release-Win32\RSP00000440643280.rsp" with contents
[
/Ox /Ob1 /Oi /Ot /GL /I "../../" /I "../../../Lua/diluculum/include" /I "../../../Lua/lua/src" /I "../../../Lua/boost" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "JUCE_RELEASE" /D "_CRT_SECURE_NO_WARNINGS" /D "_UNICODE" /D "UNICODE" /GF /FD /EHsc /MD /Gy /fp:fast /Fo"Release-Win32\\" /Fd"Release-Win32\EdoController.pdb" /W3 /c /TP  /MP4

..\..\Primitives\file.cpp
]
Creating command line "cl.exe @"c:\devel\ctrlr\EdoController\Build\Win\Release-Win32\RSP00000440643280.rsp" /nologo /errorReport:prompt"
Output Window	 	
Compiling...
file.cpp
Results
Build log was saved at "file://c:\devel\ctrlr\EdoController\Build\Win\Release-Win32\BuildLog.htm"
EdoController - 0 error(s), 0 warning(s)

#6

If it’s a template, then the function won’t be fully parsed until you actually use it somewhere. Presumably you’re only calling it in your mac build.


#7

perhaps


#8

Clean the project and try building it again.


#9

I don’t think that needs to be the case. At least on Leopard and the older XCode/GCC, it seems to link to everything regardless of whether that stuff will actually end up in the binary. I’ve been caught out a few times with pure virtual methods for half written classes that I’ve forgotten about because VS ignores them. As soon as I try to build on OSX I’m rudely alerted to my lack of project organization.