Visual Studio and Structures












2















I’m trying to port an application written for a micro to Visual Studio so I can more easily run the debugger and scan through the code, rather than debug on the chip which is a bit of a pain when you want to learn how the application was written. I’m not at all a programming guru, and I keep getting this error, listed below, which is related to a structure:



error C2059: syntax error : '.'


The code is listed below, can anyone point me in the right direction.



typedef struct usart_reg_map 
{
volatile uint32 SR;
volatile uint32 DR;
volatile uint32 BRR;
volatile uint32 CR1;
volatile uint32 CR2;
volatile uint32 CR3;
volatile uint32 GTPR;
}usart_reg_map;

#define USART1_BASE ((struct usart_reg_map*))

typedef struct usart_dev
{
usart_reg_map *regs;
}usart_dev;

struct usart_dev usart1 =
{
.regs = USART1_BASE,
};

usart_dev *USART1 = &usart1;









share|improve this question













migrated from electronics.stackexchange.com Feb 5 at 11:13


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.














  • 2





    It's probably .regs = USART1_BASE, which looks non-standard, but none of that UART code is going to work on a PC without a bunch of changes.

    – PeterJ
    Feb 1 at 11:21






  • 3





    @PeterJ it is a designated initializer. The OP should make sure that compiler flags are set to support C99 which is the standard that added this.

    – replete
    Feb 1 at 11:23






  • 4





    My main point is if it compiles it won't work anyway on a PC - when you try to access 0x40013800 you'll get an access violation because that's not where a PC UART is and under Windows you need to access a com port an entirely different way, for example you open it with a Win32 CreateFile call.

    – PeterJ
    Feb 1 at 11:31






  • 1





    Visual Studio does not fully support C99 and does not intend to. I would strongly advice you to consider using another compiler, e.g. GCC.

    – Morten Jensen
    Feb 1 at 13:40






  • 1





    Overall, it rather sounds like you should invest in a better in-circuit debugger for your MCU. Trust me, there is no better way to learn than to run the code on the actual hardware. It sounds like the root of your problem is some toxic tool chain like Eclipse, in which case the solution is to get something better.

    – Lundin
    Feb 1 at 14:00
















2















I’m trying to port an application written for a micro to Visual Studio so I can more easily run the debugger and scan through the code, rather than debug on the chip which is a bit of a pain when you want to learn how the application was written. I’m not at all a programming guru, and I keep getting this error, listed below, which is related to a structure:



error C2059: syntax error : '.'


The code is listed below, can anyone point me in the right direction.



typedef struct usart_reg_map 
{
volatile uint32 SR;
volatile uint32 DR;
volatile uint32 BRR;
volatile uint32 CR1;
volatile uint32 CR2;
volatile uint32 CR3;
volatile uint32 GTPR;
}usart_reg_map;

#define USART1_BASE ((struct usart_reg_map*))

typedef struct usart_dev
{
usart_reg_map *regs;
}usart_dev;

struct usart_dev usart1 =
{
.regs = USART1_BASE,
};

usart_dev *USART1 = &usart1;









share|improve this question













migrated from electronics.stackexchange.com Feb 5 at 11:13


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.














  • 2





    It's probably .regs = USART1_BASE, which looks non-standard, but none of that UART code is going to work on a PC without a bunch of changes.

    – PeterJ
    Feb 1 at 11:21






  • 3





    @PeterJ it is a designated initializer. The OP should make sure that compiler flags are set to support C99 which is the standard that added this.

    – replete
    Feb 1 at 11:23






  • 4





    My main point is if it compiles it won't work anyway on a PC - when you try to access 0x40013800 you'll get an access violation because that's not where a PC UART is and under Windows you need to access a com port an entirely different way, for example you open it with a Win32 CreateFile call.

    – PeterJ
    Feb 1 at 11:31






  • 1





    Visual Studio does not fully support C99 and does not intend to. I would strongly advice you to consider using another compiler, e.g. GCC.

    – Morten Jensen
    Feb 1 at 13:40






  • 1





    Overall, it rather sounds like you should invest in a better in-circuit debugger for your MCU. Trust me, there is no better way to learn than to run the code on the actual hardware. It sounds like the root of your problem is some toxic tool chain like Eclipse, in which case the solution is to get something better.

    – Lundin
    Feb 1 at 14:00














2












2








2








I’m trying to port an application written for a micro to Visual Studio so I can more easily run the debugger and scan through the code, rather than debug on the chip which is a bit of a pain when you want to learn how the application was written. I’m not at all a programming guru, and I keep getting this error, listed below, which is related to a structure:



error C2059: syntax error : '.'


The code is listed below, can anyone point me in the right direction.



typedef struct usart_reg_map 
{
volatile uint32 SR;
volatile uint32 DR;
volatile uint32 BRR;
volatile uint32 CR1;
volatile uint32 CR2;
volatile uint32 CR3;
volatile uint32 GTPR;
}usart_reg_map;

#define USART1_BASE ((struct usart_reg_map*))

typedef struct usart_dev
{
usart_reg_map *regs;
}usart_dev;

struct usart_dev usart1 =
{
.regs = USART1_BASE,
};

usart_dev *USART1 = &usart1;









share|improve this question














I’m trying to port an application written for a micro to Visual Studio so I can more easily run the debugger and scan through the code, rather than debug on the chip which is a bit of a pain when you want to learn how the application was written. I’m not at all a programming guru, and I keep getting this error, listed below, which is related to a structure:



error C2059: syntax error : '.'


The code is listed below, can anyone point me in the right direction.



typedef struct usart_reg_map 
{
volatile uint32 SR;
volatile uint32 DR;
volatile uint32 BRR;
volatile uint32 CR1;
volatile uint32 CR2;
volatile uint32 CR3;
volatile uint32 GTPR;
}usart_reg_map;

#define USART1_BASE ((struct usart_reg_map*))

typedef struct usart_dev
{
usart_reg_map *regs;
}usart_dev;

struct usart_dev usart1 =
{
.regs = USART1_BASE,
};

usart_dev *USART1 = &usart1;






microcontroller c c++






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 1 at 11:00







kvresto











migrated from electronics.stackexchange.com Feb 5 at 11:13


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.









migrated from electronics.stackexchange.com Feb 5 at 11:13


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.










  • 2





    It's probably .regs = USART1_BASE, which looks non-standard, but none of that UART code is going to work on a PC without a bunch of changes.

    – PeterJ
    Feb 1 at 11:21






  • 3





    @PeterJ it is a designated initializer. The OP should make sure that compiler flags are set to support C99 which is the standard that added this.

    – replete
    Feb 1 at 11:23






  • 4





    My main point is if it compiles it won't work anyway on a PC - when you try to access 0x40013800 you'll get an access violation because that's not where a PC UART is and under Windows you need to access a com port an entirely different way, for example you open it with a Win32 CreateFile call.

    – PeterJ
    Feb 1 at 11:31






  • 1





    Visual Studio does not fully support C99 and does not intend to. I would strongly advice you to consider using another compiler, e.g. GCC.

    – Morten Jensen
    Feb 1 at 13:40






  • 1





    Overall, it rather sounds like you should invest in a better in-circuit debugger for your MCU. Trust me, there is no better way to learn than to run the code on the actual hardware. It sounds like the root of your problem is some toxic tool chain like Eclipse, in which case the solution is to get something better.

    – Lundin
    Feb 1 at 14:00














  • 2





    It's probably .regs = USART1_BASE, which looks non-standard, but none of that UART code is going to work on a PC without a bunch of changes.

    – PeterJ
    Feb 1 at 11:21






  • 3





    @PeterJ it is a designated initializer. The OP should make sure that compiler flags are set to support C99 which is the standard that added this.

    – replete
    Feb 1 at 11:23






  • 4





    My main point is if it compiles it won't work anyway on a PC - when you try to access 0x40013800 you'll get an access violation because that's not where a PC UART is and under Windows you need to access a com port an entirely different way, for example you open it with a Win32 CreateFile call.

    – PeterJ
    Feb 1 at 11:31






  • 1





    Visual Studio does not fully support C99 and does not intend to. I would strongly advice you to consider using another compiler, e.g. GCC.

    – Morten Jensen
    Feb 1 at 13:40






  • 1





    Overall, it rather sounds like you should invest in a better in-circuit debugger for your MCU. Trust me, there is no better way to learn than to run the code on the actual hardware. It sounds like the root of your problem is some toxic tool chain like Eclipse, in which case the solution is to get something better.

    – Lundin
    Feb 1 at 14:00








2




2





It's probably .regs = USART1_BASE, which looks non-standard, but none of that UART code is going to work on a PC without a bunch of changes.

– PeterJ
Feb 1 at 11:21





It's probably .regs = USART1_BASE, which looks non-standard, but none of that UART code is going to work on a PC without a bunch of changes.

– PeterJ
Feb 1 at 11:21




3




3





@PeterJ it is a designated initializer. The OP should make sure that compiler flags are set to support C99 which is the standard that added this.

– replete
Feb 1 at 11:23





@PeterJ it is a designated initializer. The OP should make sure that compiler flags are set to support C99 which is the standard that added this.

– replete
Feb 1 at 11:23




4




4





My main point is if it compiles it won't work anyway on a PC - when you try to access 0x40013800 you'll get an access violation because that's not where a PC UART is and under Windows you need to access a com port an entirely different way, for example you open it with a Win32 CreateFile call.

– PeterJ
Feb 1 at 11:31





My main point is if it compiles it won't work anyway on a PC - when you try to access 0x40013800 you'll get an access violation because that's not where a PC UART is and under Windows you need to access a com port an entirely different way, for example you open it with a Win32 CreateFile call.

– PeterJ
Feb 1 at 11:31




1




1





Visual Studio does not fully support C99 and does not intend to. I would strongly advice you to consider using another compiler, e.g. GCC.

– Morten Jensen
Feb 1 at 13:40





Visual Studio does not fully support C99 and does not intend to. I would strongly advice you to consider using another compiler, e.g. GCC.

– Morten Jensen
Feb 1 at 13:40




1




1





Overall, it rather sounds like you should invest in a better in-circuit debugger for your MCU. Trust me, there is no better way to learn than to run the code on the actual hardware. It sounds like the root of your problem is some toxic tool chain like Eclipse, in which case the solution is to get something better.

– Lundin
Feb 1 at 14:00





Overall, it rather sounds like you should invest in a better in-circuit debugger for your MCU. Trust me, there is no better way to learn than to run the code on the actual hardware. It sounds like the root of your problem is some toxic tool chain like Eclipse, in which case the solution is to get something better.

– Lundin
Feb 1 at 14:00










3 Answers
3






active

oldest

votes


















1














In all cases it is a lot of work, but it is possible:




  1. Find out which classes, structures, types and functions you need from the micro libaries.

  2. Create files for them, similar to the micros libraries, preferably about the same file structure, but in a different location. These will only run in the PC version.

  3. Create a new project for the non micro environment, where the files in step 2 are used instead of 1. This can be done by changing the include path probably.


In step 2, you can make even some intelligence in the functions if you want to test that.
Also you do not need to change any file that runs on the micro that you created yourself, because only the micro libraries have a PC counterpart.



About C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.






share|improve this answer
























  • Yep, your correct, its a lot of work. I just read in another post C99 is not supported in VS for C, so I just lost my enthusiasm, as there are dozens of these structures and some are very lengthy.

    – kvresto
    Feb 1 at 12:02











  • but you only need to add what you use directly. What you also could do but its also tricky is to make some generic functions with input parameter types which are known by both the microcontroller and VS, and in the microcontroller map them to the real microcontroller types; this means you have to make extra 'facade' classes/functions in between.

    – Michel Keijzers
    Feb 1 at 12:04











  • about C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.

    – Michel Keijzers
    Feb 1 at 12:07











  • Good advice Michel.

    – kvresto
    Feb 1 at 12:11



















1














There's two issues to consider:




  • Most likely you are compiling the code as C++. But C++ is not C and vice versa - they are not compatible languages. You need to enforce C compilation, which is typically done by naming your file .c instead of .cpp.


  • Even in C mode, Visual Studio has horrible support for standard C. The . initialization syntax is known as designated initializers and was introduced in the language year 1999. Microsoft has however insisted not to upgrade their C compiler, until some half-hearted attempt a few years ago. They may or may not support designated initializers, I don't know.



I would strongly recommend any beginner programmer to use a standard-compilant compiler instead. You can tell VS to use the gcc compiler instead of the default crap one, or you can download another IDE such as Codeblocks, which comes with gcc/mingw pre-installed per default.






share|improve this answer
























  • I second this. Get a GCC-based compiler chain for windows, if you want to compile C99.

    – Morten Jensen
    Feb 4 at 12:43



















0














Your specific problem is because, as you have discovered, the designated initializer .regs = USART1_BASE does not work in Visual Studio.



I usually use GCC and a makefile when testing my microcontroller projects on windows. This seems to work a lot better when trying to use features from a specific standard like C99.



As others have pointed out, you will likely have to do a lot of refactoring to make your entire project actually run on Windows. I usually break my project up into simple modules that I can compile and test on Windows with GCC, and then combine those well tested modules into a larger app that I can run and test on the target device.






share|improve this answer





























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    In all cases it is a lot of work, but it is possible:




    1. Find out which classes, structures, types and functions you need from the micro libaries.

    2. Create files for them, similar to the micros libraries, preferably about the same file structure, but in a different location. These will only run in the PC version.

    3. Create a new project for the non micro environment, where the files in step 2 are used instead of 1. This can be done by changing the include path probably.


    In step 2, you can make even some intelligence in the functions if you want to test that.
    Also you do not need to change any file that runs on the micro that you created yourself, because only the micro libraries have a PC counterpart.



    About C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.






    share|improve this answer
























    • Yep, your correct, its a lot of work. I just read in another post C99 is not supported in VS for C, so I just lost my enthusiasm, as there are dozens of these structures and some are very lengthy.

      – kvresto
      Feb 1 at 12:02











    • but you only need to add what you use directly. What you also could do but its also tricky is to make some generic functions with input parameter types which are known by both the microcontroller and VS, and in the microcontroller map them to the real microcontroller types; this means you have to make extra 'facade' classes/functions in between.

      – Michel Keijzers
      Feb 1 at 12:04











    • about C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.

      – Michel Keijzers
      Feb 1 at 12:07











    • Good advice Michel.

      – kvresto
      Feb 1 at 12:11
















    1














    In all cases it is a lot of work, but it is possible:




    1. Find out which classes, structures, types and functions you need from the micro libaries.

    2. Create files for them, similar to the micros libraries, preferably about the same file structure, but in a different location. These will only run in the PC version.

    3. Create a new project for the non micro environment, where the files in step 2 are used instead of 1. This can be done by changing the include path probably.


    In step 2, you can make even some intelligence in the functions if you want to test that.
    Also you do not need to change any file that runs on the micro that you created yourself, because only the micro libraries have a PC counterpart.



    About C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.






    share|improve this answer
























    • Yep, your correct, its a lot of work. I just read in another post C99 is not supported in VS for C, so I just lost my enthusiasm, as there are dozens of these structures and some are very lengthy.

      – kvresto
      Feb 1 at 12:02











    • but you only need to add what you use directly. What you also could do but its also tricky is to make some generic functions with input parameter types which are known by both the microcontroller and VS, and in the microcontroller map them to the real microcontroller types; this means you have to make extra 'facade' classes/functions in between.

      – Michel Keijzers
      Feb 1 at 12:04











    • about C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.

      – Michel Keijzers
      Feb 1 at 12:07











    • Good advice Michel.

      – kvresto
      Feb 1 at 12:11














    1












    1








    1







    In all cases it is a lot of work, but it is possible:




    1. Find out which classes, structures, types and functions you need from the micro libaries.

    2. Create files for them, similar to the micros libraries, preferably about the same file structure, but in a different location. These will only run in the PC version.

    3. Create a new project for the non micro environment, where the files in step 2 are used instead of 1. This can be done by changing the include path probably.


    In step 2, you can make even some intelligence in the functions if you want to test that.
    Also you do not need to change any file that runs on the micro that you created yourself, because only the micro libraries have a PC counterpart.



    About C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.






    share|improve this answer













    In all cases it is a lot of work, but it is possible:




    1. Find out which classes, structures, types and functions you need from the micro libaries.

    2. Create files for them, similar to the micros libraries, preferably about the same file structure, but in a different location. These will only run in the PC version.

    3. Create a new project for the non micro environment, where the files in step 2 are used instead of 1. This can be done by changing the include path probably.


    In step 2, you can make even some intelligence in the functions if you want to test that.
    Also you do not need to change any file that runs on the micro that you created yourself, because only the micro libraries have a PC counterpart.



    About C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 1 at 11:48









    Michel KeijzersMichel Keijzers

    2362616




    2362616













    • Yep, your correct, its a lot of work. I just read in another post C99 is not supported in VS for C, so I just lost my enthusiasm, as there are dozens of these structures and some are very lengthy.

      – kvresto
      Feb 1 at 12:02











    • but you only need to add what you use directly. What you also could do but its also tricky is to make some generic functions with input parameter types which are known by both the microcontroller and VS, and in the microcontroller map them to the real microcontroller types; this means you have to make extra 'facade' classes/functions in between.

      – Michel Keijzers
      Feb 1 at 12:04











    • about C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.

      – Michel Keijzers
      Feb 1 at 12:07











    • Good advice Michel.

      – kvresto
      Feb 1 at 12:11



















    • Yep, your correct, its a lot of work. I just read in another post C99 is not supported in VS for C, so I just lost my enthusiasm, as there are dozens of these structures and some are very lengthy.

      – kvresto
      Feb 1 at 12:02











    • but you only need to add what you use directly. What you also could do but its also tricky is to make some generic functions with input parameter types which are known by both the microcontroller and VS, and in the microcontroller map them to the real microcontroller types; this means you have to make extra 'facade' classes/functions in between.

      – Michel Keijzers
      Feb 1 at 12:04











    • about C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.

      – Michel Keijzers
      Feb 1 at 12:07











    • Good advice Michel.

      – kvresto
      Feb 1 at 12:11

















    Yep, your correct, its a lot of work. I just read in another post C99 is not supported in VS for C, so I just lost my enthusiasm, as there are dozens of these structures and some are very lengthy.

    – kvresto
    Feb 1 at 12:02





    Yep, your correct, its a lot of work. I just read in another post C99 is not supported in VS for C, so I just lost my enthusiasm, as there are dozens of these structures and some are very lengthy.

    – kvresto
    Feb 1 at 12:02













    but you only need to add what you use directly. What you also could do but its also tricky is to make some generic functions with input parameter types which are known by both the microcontroller and VS, and in the microcontroller map them to the real microcontroller types; this means you have to make extra 'facade' classes/functions in between.

    – Michel Keijzers
    Feb 1 at 12:04





    but you only need to add what you use directly. What you also could do but its also tricky is to make some generic functions with input parameter types which are known by both the microcontroller and VS, and in the microcontroller map them to the real microcontroller types; this means you have to make extra 'facade' classes/functions in between.

    – Michel Keijzers
    Feb 1 at 12:04













    about C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.

    – Michel Keijzers
    Feb 1 at 12:07





    about C99, make sure that you don't use C99 specific features in the generic code (your microcontroller code), and if you need it, make that code in separate functions which you could either port to VS, or maybe they are not needed as they are part of the microcontroller libraries or facade functions.

    – Michel Keijzers
    Feb 1 at 12:07













    Good advice Michel.

    – kvresto
    Feb 1 at 12:11





    Good advice Michel.

    – kvresto
    Feb 1 at 12:11













    1














    There's two issues to consider:




    • Most likely you are compiling the code as C++. But C++ is not C and vice versa - they are not compatible languages. You need to enforce C compilation, which is typically done by naming your file .c instead of .cpp.


    • Even in C mode, Visual Studio has horrible support for standard C. The . initialization syntax is known as designated initializers and was introduced in the language year 1999. Microsoft has however insisted not to upgrade their C compiler, until some half-hearted attempt a few years ago. They may or may not support designated initializers, I don't know.



    I would strongly recommend any beginner programmer to use a standard-compilant compiler instead. You can tell VS to use the gcc compiler instead of the default crap one, or you can download another IDE such as Codeblocks, which comes with gcc/mingw pre-installed per default.






    share|improve this answer
























    • I second this. Get a GCC-based compiler chain for windows, if you want to compile C99.

      – Morten Jensen
      Feb 4 at 12:43
















    1














    There's two issues to consider:




    • Most likely you are compiling the code as C++. But C++ is not C and vice versa - they are not compatible languages. You need to enforce C compilation, which is typically done by naming your file .c instead of .cpp.


    • Even in C mode, Visual Studio has horrible support for standard C. The . initialization syntax is known as designated initializers and was introduced in the language year 1999. Microsoft has however insisted not to upgrade their C compiler, until some half-hearted attempt a few years ago. They may or may not support designated initializers, I don't know.



    I would strongly recommend any beginner programmer to use a standard-compilant compiler instead. You can tell VS to use the gcc compiler instead of the default crap one, or you can download another IDE such as Codeblocks, which comes with gcc/mingw pre-installed per default.






    share|improve this answer
























    • I second this. Get a GCC-based compiler chain for windows, if you want to compile C99.

      – Morten Jensen
      Feb 4 at 12:43














    1












    1








    1







    There's two issues to consider:




    • Most likely you are compiling the code as C++. But C++ is not C and vice versa - they are not compatible languages. You need to enforce C compilation, which is typically done by naming your file .c instead of .cpp.


    • Even in C mode, Visual Studio has horrible support for standard C. The . initialization syntax is known as designated initializers and was introduced in the language year 1999. Microsoft has however insisted not to upgrade their C compiler, until some half-hearted attempt a few years ago. They may or may not support designated initializers, I don't know.



    I would strongly recommend any beginner programmer to use a standard-compilant compiler instead. You can tell VS to use the gcc compiler instead of the default crap one, or you can download another IDE such as Codeblocks, which comes with gcc/mingw pre-installed per default.






    share|improve this answer













    There's two issues to consider:




    • Most likely you are compiling the code as C++. But C++ is not C and vice versa - they are not compatible languages. You need to enforce C compilation, which is typically done by naming your file .c instead of .cpp.


    • Even in C mode, Visual Studio has horrible support for standard C. The . initialization syntax is known as designated initializers and was introduced in the language year 1999. Microsoft has however insisted not to upgrade their C compiler, until some half-hearted attempt a few years ago. They may or may not support designated initializers, I don't know.



    I would strongly recommend any beginner programmer to use a standard-compilant compiler instead. You can tell VS to use the gcc compiler instead of the default crap one, or you can download another IDE such as Codeblocks, which comes with gcc/mingw pre-installed per default.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 1 at 13:56







    Lundin




















    • I second this. Get a GCC-based compiler chain for windows, if you want to compile C99.

      – Morten Jensen
      Feb 4 at 12:43



















    • I second this. Get a GCC-based compiler chain for windows, if you want to compile C99.

      – Morten Jensen
      Feb 4 at 12:43

















    I second this. Get a GCC-based compiler chain for windows, if you want to compile C99.

    – Morten Jensen
    Feb 4 at 12:43





    I second this. Get a GCC-based compiler chain for windows, if you want to compile C99.

    – Morten Jensen
    Feb 4 at 12:43











    0














    Your specific problem is because, as you have discovered, the designated initializer .regs = USART1_BASE does not work in Visual Studio.



    I usually use GCC and a makefile when testing my microcontroller projects on windows. This seems to work a lot better when trying to use features from a specific standard like C99.



    As others have pointed out, you will likely have to do a lot of refactoring to make your entire project actually run on Windows. I usually break my project up into simple modules that I can compile and test on Windows with GCC, and then combine those well tested modules into a larger app that I can run and test on the target device.






    share|improve this answer




























      0














      Your specific problem is because, as you have discovered, the designated initializer .regs = USART1_BASE does not work in Visual Studio.



      I usually use GCC and a makefile when testing my microcontroller projects on windows. This seems to work a lot better when trying to use features from a specific standard like C99.



      As others have pointed out, you will likely have to do a lot of refactoring to make your entire project actually run on Windows. I usually break my project up into simple modules that I can compile and test on Windows with GCC, and then combine those well tested modules into a larger app that I can run and test on the target device.






      share|improve this answer


























        0












        0








        0







        Your specific problem is because, as you have discovered, the designated initializer .regs = USART1_BASE does not work in Visual Studio.



        I usually use GCC and a makefile when testing my microcontroller projects on windows. This seems to work a lot better when trying to use features from a specific standard like C99.



        As others have pointed out, you will likely have to do a lot of refactoring to make your entire project actually run on Windows. I usually break my project up into simple modules that I can compile and test on Windows with GCC, and then combine those well tested modules into a larger app that I can run and test on the target device.






        share|improve this answer













        Your specific problem is because, as you have discovered, the designated initializer .regs = USART1_BASE does not work in Visual Studio.



        I usually use GCC and a makefile when testing my microcontroller projects on windows. This seems to work a lot better when trying to use features from a specific standard like C99.



        As others have pointed out, you will likely have to do a lot of refactoring to make your entire project actually run on Windows. I usually break my project up into simple modules that I can compile and test on Windows with GCC, and then combine those well tested modules into a larger app that I can run and test on the target device.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 1 at 12:40









        cholzcholz

        11




        11















            Popular posts from this blog

            How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

            is 'sed' thread safe

            How to make a Squid Proxy server?