error CS1032: Cannot define/undefine preprocessor symbols after first token in file
Dear developer(s) of labstreaminglayer,
I want to log head orientation data at a relatively high frequency in my Unity application and found your tool, which seems the perfect thing to solve my issue!
However, when following your wiki instructions on integrating LSL into my Unity project, I immediately got an error. When I place the folders of LSL into my assets folder in Unity, the following error compes up:
Assets\LSL4Unity\LSL.cs(5,2): error CS1032: Cannot define/undefine preprocessor symbols after first token in file
I am assume this is some compatibility issue with .NET? I am using Unity version 2019.1.2f1 Personal with .NET 4.x Equivalent.
I cannot downgrade .NET, because I had to upgrade to solve some other bugs. I also cannot easily check whether things work in a different Unity version, because I am using Oculus utilities and they don't always work well in different Unity versions.
When googling the error I found something on the .NET page (https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs1032), but this is not comprehensible to me.
Do you have any ideas on how to solve this issue?
Thanks anyway for developing this great tool! Kind regards, Hanne Huygelier
There was a recent change to LSL.cs (commit here). I'm not sure why it was added but it causes this problem for us too. @argzero do you think you could remove it and find another solution to your issue?
In any case, if all you need is LSL.cs, then please use the version here: https://github.com/labstreaminglayer/liblsl-Csharp Eventually this will be the only version of LSL.cs and this LSL4Unity repo will have to be refactored somewhat to use that LSL.cs, though I don't know how to do that just yet.
Thank you for the quick response!
I changed the LSL version to the one you recommended. However, I now get a new error:
error CS1519: Invalid token '=' in class, struct, or interface member declaration
I noticed that it was because there was no "const string" before liblsl, so I adjusted that on lines 888 and 885, but this just gives rise to many new errors.
So I am assuming the current LSL version is not compatible with .Net 4.0 or with something else in my project?
Thanks in advance!
It's compatible. That's not the problem.
I guess you're just on a code path that I didn't test. What OS and architecture are you on?
Windows 10 and architecture X86_64.
You're right about the const string, sorry for missing that before. My tests of that LSL.cs file were in a regular C# project, not Unity, so that #if block wasn't triggered.
But, after adding that, my colleague just tested LSL.cs in his Unity project with .Net 4.x and it worked fine.
The errors that come up are all similar like this one:
The namespace 'ConsoleApplication1' already contains a definition for 'Program'
This error pops up from each of the scripts in the examples that define "ConsoleApplication1".
Ah, sorry I can't help you with LSL4Unity examples. In our Unity projects we only use LSL.cs (and the required liblsl64.dll). I think it's completely possible that the LSL4Unity examples are out-dated and might not work with the latest Unity and/or latest .Net framework.
The good news is that LSL.cs (and the dll) work fine in Unity and really that's all you need to get going with LSL in Unity.
I just realized that you might have been referring to the examples in liblsl-Csharp. Those are not intended to be used in Unity. Those are intended to be used as standalone C# executables.
Ah okay, I am sorry for bothering you.
Not at all. In the "Getting Help" paragraph in the main repository (here), there's a link for a Slack invite. Please join if you'd prefer a real-time conversation over the back-and-forth in GitHub issues.