question

kavehrahimi-5744 avatar image
0 Votes"
kavehrahimi-5744 asked SimpleSamples commented

C1075 error

Hi , I'm noob in 'c++' I debug my code and receive 'C1075' error. '{': no matching token found. I've used an anonymous namespace. I don't know why I receive this error.
Please help me.
Thanks

c++
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Show the relevant portion of your code.
Presumably you're not debugging it if you can't get it to compile.

0 Votes 0 ·
WayneAKing-0228 avatar image
0 Votes"
WayneAKing-0228 answered

I don't know why I receive this error.

Fatal Error C1075

https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1075?view=msvc-160

"the left token was unmatched at the end of the file
The compiler expected matching token before it reached the end of file.
This error can be caused by an unmatched bracket,
brace, or other paired character."

  • Wayne


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimpleSamples avatar image
0 Votes"
SimpleSamples answered SimpleSamples commented

We do not know if the { is an extra one or if you are missing an ending }; that is why showing the relevant code would help. You can try deleting (or commenting out) the { but if the problem is that you instead need a } then it will be difficult to help you without seeing the code.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This is my code:

pragma warning(disable:4101 65)

pragma warning(disable:5046 2)

pragma warning(default:4716)

include "ch341dll.h"

pragma comment(lib, "CH341DLL.LIB")

include <windows.h>

include <iostream>

include <cstdlib>

namespace
{

ifndef _CH341_DLL_H

define _CH341_DLL_H

................................................

 int main(void) {
     typedef        VOID(CALLBACK    * mPCH341_NOTIFY_ROUTINE) (  // É豸ʼþ֪ͨ»Øµ÷³ÌÐò
         ULONG            iEventStatus);  // É豸ʼþºÍµ±Ç°×´Ì¬(ÔÚÏÂÐж¨Òå): 0=É豸°Î³öʼþ, 3=É豸²åÈëʼþ

define CH341_DEVICE_ARRIVAL 3 // É豸²åÈëʼþ,ÒѾ­²åÈë

define CH341_DEVICE_REMOVE_PEND 1 // É豸½«Òª°Î³ö

define CH341_DEVICE_REMOVE 0 // É豸°Î³öʼþ,ÒѾ­°Î³ö




     extern        BOOL    WINAPI    CH341SetDeviceNotify(  // É趨É豸ʼþ֪ͨ³ÌÐò
         ULONG                    iIndex,  // Ö¸¶¨CH341É豸ÐòºÅ,0¶ÔÓ¦µÚÒ»¸öÉ豸
         PCHAR                    iDeviceID,  // ¿ÉÑ¡²ÎÊý,Ö¸Ïò×Ö·û´®,Ö¸¶¨±»¼à¿ØµÄÉ豸µÄID,×Ö·û´®ÒÔ\0ÖÕÖ¹
         mPCH341_NOTIFY_ROUTINE    iNotifyRoutine);  // Ö¸¶¨É豸ʼþ»Øµ÷³ÌÐò,ΪNULLÔòÈ¡Ïûʼþ֪ͨ,·ñÔòÔÚ¼ì²âµ½Ê¼þʱµ÷ÓøóÌÐò
     ULONG    iIndex = 0;
     PCHAR iDeviceID = 0;
     mPCH341_NOTIFY_ROUTINE    iNotifyRoutine = 0;
     if (CH341SetDeviceNotify(iIndex, iDeviceID, iNotifyRoutine)) {
         std::cout << "USB PORT CONNECTED";
     }
 }


ifdef __cplusplus



endif


endif // _CH341_DLL_H

}

This is a sammary of my code.

0 Votes 0 ·

Showing us manually entered (as opposed to copy and paste) excerpts of your code serves no purpose. Since you have not found the mismatch yourself, odds are it is an area you chose not to show us.

When viewing the code in the Visual Studio editor, if you place the cursor to the immediate left of an open brace ({), VS will highlight the corresponding closing brace (}). The reverse is also true. This should let you see which open brace is not matched with a closing one or not with the one you wanted it to be matched with.

Furthermore, if you have enabled outlining, you can shrink a compound statement to a single line to help remove the clutter while you search for the unmatched brace.

If you let the editor perform indenting, it will also line up matching braces at consistent indent levels.

0 Votes 0 ·

If that truly is your code then one huge problem is that every pragma, include, ifndef, ifdef and endif must be preceded by a # as in #pragma, #include, #ifndef, #ifdef and #endif. You need to add the # to all of those. If they already have the # then we need to see the code exactly as it is.

0 Votes 0 ·