# Help with note-c-master on Microsoft Visual Studio

**URL:** https://discuss.blues.com/t/help-with-note-c-master-on-microsoft-visual-studio/246
**Category:** Tools & SDKs
**Created:** [May 4, 2021, 2:57pm UTC](https://discuss.blues.com/t/help-with-note-c-master-on-microsoft-visual-studio/246 "2021-05-04T14:57:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![BrianP](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@BrianP](https://discuss.blues.com/u/BrianP)
#### Post date: [May 4, 2021, 2:57pm UTC](https://discuss.blues.com/t/help-with-note-c-master-on-microsoft-visual-studio/246/1 "2021-05-04T14:57:40Z")

</div>

Thanks in advance for the help.

I am putting together a software prototype to test my Notecard. I have found it easier to build prototypes on MSVC because my embedded platform tends to be Atmel Studio. Thus I avoid the horrors of Arduino and having to burn code into a board to get started.

The note-c-master library appear written for gcc, which has  
**attribute** ((weak)) // underscore underscore attribute underscore underscore ((weak))

(see in n\_str.c used twice)

Microsoft C doesn’t support **attribute** ((weak)). It seems the equivalent is

\_\_declspec(selectany) //underscore underscore declspec

Changing the code to \_\_declspec(selectany) removes most of the errors but results in 2 errors

Error C2496 ‘strlcpy’: ‘selectany’ can only be applied to data items with external linkage

However, simply removing **attribute** ((weak)) allows the code to compile.

The problem is I have no idea what **attribute** ((weak)) does so I don’t know whether this will cause a problem down the line.

This is obviously not urgent but since I am not the only person who uses MSVC it might be worth addressing.

Thanks

---

<div class="post-metadata">

### Author: ![gwolff](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@gwolff](https://discuss.blues.com/u/gwolff)
#### Post date: [May 4, 2021, 3:14pm UTC](https://discuss.blues.com/t/help-with-note-c-master-on-microsoft-visual-studio/246/2 "2021-05-04T15:14:16Z")

</div>

Hi Brian,

There are some options for compiling with Windows. See the comments here:

> <https://github.com/blues/note-c/blob/1733b23251212fed709aefeced6ae8e530c63418/n_cjson.h#L105>

**However** : I don’t think it resolves your specific case as **attribute(weak)** is hard-coded in `n_str.c`. Let me see what we can do, and I’ll follow up.

---

<div class="post-metadata">

### Author: ![BrianP](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@BrianP](https://discuss.blues.com/u/BrianP)
#### Post date: [May 4, 2021, 3:40pm UTC](https://discuss.blues.com/t/help-with-note-c-master-on-microsoft-visual-studio/246/3 "2021-05-04T15:40:50Z")

</div>

Indeed, I verified that that path is taken by the compiler but the problem remains. No rush: I can apparently get things to compile so I’ll be able to step through, etc.

edit this is what I did  
#if defined(\_MSC\_VER)  
size\_t strlcat(char\* dst, const char\* src, size\_t siz)  
#else  
**attribute** ((weak)) size\_t strlcat(char\* dst, const char\* src, size\_t siz)  
#endif

Since the issue is the use of the Microsoft compiler, not the Windows OS

Thanks

---

<div class="post-metadata">

### Author: ![gwolff](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@gwolff](https://discuss.blues.com/u/gwolff)
#### Post date: [May 4, 2021, 9:52pm UTC](https://discuss.blues.com/t/help-with-note-c-master-on-microsoft-visual-studio/246/4 "2021-05-04T21:52:28Z")

</div>

Hi Brian,

We updated the `note-c` files to include your recommended change

[GitHub - blues/note-c: C API for Notecard](https://github.com/blues/note-c)

Cheer!

---

<div class="post-metadata">

### Author: ![BrianP](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@BrianP](https://discuss.blues.com/u/BrianP)
#### Post date: [May 4, 2021, 11:54pm UTC](https://discuss.blues.com/t/help-with-note-c-master-on-microsoft-visual-studio/246/5 "2021-05-04T23:54:31Z")

</div>

Great! I have a few other observations but I’ll hold off until I get everything working.
